Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    No AfterUpdate Event From Calendar Date Picker? (A2k (9.0.3821) SR-1)

    I have a Start Date field that has an AfterUpdate Event that fires when a date is entered to calculate a expiration date in another control. And it works OK.

    I can double click on the Start Date field to pop up a date picker calendar control (from Scott Cybak), when I pick a date from the calendar control the Start Date is populated OK, however the Start Date AfterUpdate Event does not fire.

    What is the best approach to fire the Start Date AfterUpdate Event when the Start Date is selected from the date picker?

    Thanks, John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: No AfterUpdate Event From Calendar Date Picker? (A2k (9.0.3821) SR-1)

    The AfterUpdate event of a control only fires if the user modifies the value of the control directly, but not if the value is modified by VBA. You can call the AfterUpdate event procedure in the OnDblClick event handler. The code could look like this:<pre>Private Sub txtStartDate_DblClick(Cancel As Integer)
    DoCmd.OpenForm "frmDatePicker", , , , , acDialog
    txtStartDate_AfterUpdate
    End Sub</pre>

    Replace txtStartDate and frmDatePicker by the actual names you have.

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: No AfterUpdate Event From Calendar Date Picker? (A2k (9.0.3821) SR-1)

    Hi Hans

    That

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: No AfterUpdate Event From Calendar Date Picker? (A2k (9.0.3821) SR-1)

    John,

    This is trickier - when you set dtmStartDate from frmDatePicker, Value and OldValue are both equal to the new value in a quick test (in Access 97 SR2), so you may not get an AfterUpdate when you need it.. You might store the value in a variable before opening the popup form. Something like this:

    Dim strValue As String
    strValue = dtmStartDate
    DoCmd.OpenForm "frmDatePicker", , , , , acDialog
    If dtmStartDate <> strValue Then
    Call dtmStartDate_AfterUpdate
    End If

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: No AfterUpdate Event From Calendar Date Picker? (A2k (9.0.3821) SR-1)

    Hi Hans

    Perfect!

    Is there a way of moving the focus to the next control in tab order in code without hardcoding dtmTime.SetFocus?

    Thanks, John

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: No AfterUpdate Event From Calendar Date Picker? (A2k (9.0.3821) SR-1)

    John,

    The simplest way is

    SendKeys "{tab}"

Posting Permissions

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