Results 1 to 7 of 7
  1. #1
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Events (A2K SP3)

    What is the proper event(s) to use on an original data input form which has a date field,
    RentPaidDate, where I want that field to update another date field, OrigARDate, if the Date in
    the first field is changed. The RentPaidDate has a calendar which the operator can use to select
    the date or the date can be entered manually. When using an AfterUpdate event and the date is
    entered manually, the OrigARDate field is changed when the RentPaidDate field is changed. The
    problem is when the operator use the calendar function, the RentDateDate changes properly but
    the OrigARDate field is not updated.

    The RentPaidDate field can be edited by using another form and I need to keep the OrigARDate

    Here is the code I am using:
    Private Sub RentPaidDate_AfterUpdate()
    If [PayID] = 7 Or [PayID] = 9 Or [PayID2] = 7 Or [PayID2] = 9 Then [OrigARDate] =
    [RentPaidDate] Else [OriginalARDate] = ""
    End Sub

    I also tried using both an After Update Event and an On Change Event with no change in the
    results.

    Any suggestions would be appreciated.

    Tom

  2. #2
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Events (A2K SP3)

    Just some air code here, it may help.

    Private Sub RentPaidDate_AfterUpdate()
    If [PayID] = 7 Or [PayID] = 9 Or [PayID2] = 7 Or [PayID2] = 9 Then
    [OrigARDate] = [RentPaidDate]
    Else
    [OriginalARDate] = Null
    End If
    End Sub

    If the fields that are mentioned as above are on the same form, I would add:

    Private Sub RentPaidDate_AfterUpdate()
    If [PayID] = 7 Or [PayID] = 9 Or [PayID2] = 7 Or [PayID2] = 9 Then
    Me.[OrigARDate] =Me. [RentPaidDate]
    Else
    Me.[OriginalARDate] = Null
    End If
    End Sub

    Or:

    Private Sub RentPaidDate_AfterUpdate()
    If Me.[PayID] = 7 Or Me.[PayID] = 9 Or Me.[PayID2] = 7 Or Me.[PayID2] = 9 Then
    Me.[OrigARDate] =Me. [RentPaidDate]
    Else
    Me.[OriginalARDate] = Null
    End If
    End Sub

    Further to this a Select Case Statement may be what you need:

    Select Case PAYID
    Case 7, 9
    Me.[Field] = Me.[Field].............

  3. #3
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Events (A2K SP3)

    Thanks for the coding assistance. I think your 3rd suggestions is the clearest. so I have incorporated that. The new code while far superior to the original, still not not solve the calendar issue.

    Thus, the new code is:
    Private Sub RentPaidDate_AfterUpdate()
    If Me.[PayID] = 7 Or Me.[PayID] = 9 Or Me.[PayID2] = 7 Or Me.[PayID2] = 9 Then
    Me.[OrigARDate] = Me.[RentPaidDate]
    Else
    Me.[OriginalARDate] = Null
    End If

    End Sub

    Does anyone have a suggestion regarding which event (s) to use?

    Tom

  4. #4
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Events (A2K SP3)

    Tom
    I think the problem resides with "After_Update"
    Updating manually will fire the code, where as Updating via code, will not.
    Although the value is changed, the field isn't Updated, therefore, no After_Update event.

    Can you use the Dirty, or Change property instead.
    Better still, post a demo (Less than 100k Zipped) and I'm sure we can solve it.

  5. #5
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Events (A2K SP3)

    Tom
    Does this help !!
    Attached Files Attached Files

  6. #6
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Events (A2K SP3)

    My quick attemp to get a postable database under 100 K has been unsuccessful. Perhaps this weekend I can shrink it to 100K.
    Also, looked at your attachment.

    I have been successful in providing code in both the Payment Method field [PayID] and {PayID2] as well as using an Afer Update and On Lost Focus Event. I am still testing to make sure the field always gets udated.

    Once again thank you for your assistance.

    Tom

  7. #7
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Events (A2K SP3)

    You're welcome

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •