Results 1 to 8 of 8
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919

    AfterUpdate not firing

    I have a "Single Record" form with a text box bound to a phone number. When I enter a number and press "Enter", the number entered disappears from the box and it is not until the focus moves elsewhere that the "AfterUpdate" event fires. I am expecting the "AfterUpdate" to fire when I press the "Enter" key, as it does with my other "Continuous" forms.

    Here's a composite screenshot of the form in design view:
    Click image for larger version. 

Name:	000.jpg 
Views:	15 
Size:	77.5 KB 
ID:	24445

    And the "AfterUpdate" event code:
    Code:
    Private Sub tbPhone_AfterUpdate()
    If Not IsNull(Me.tbPhone) Then Me.tbPhone = FmtPhoneNos(Me.tbPhone)
    End Sub
    I've tried adding an "On Enter" event in which I tried to force updating the record via the Dirty property, but couldn't get the "AfterUpdate" to fire even with that action.

    What am I missing?

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    you seem to have a problem with understanding the order of events and when they fire - these two link many help to clarify

    http://sourcedaddy.com/ms-access/event-sequence.html

    https://support.office.com/en-us/art...ad=US&fromAR=1

    Looks like you are trying to format a number that has been entered - why not just use the format property on the control?

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    In a bound text box on a continuous form, the "AfterUpdate" fires after entering a number and pressing the "Enter" key (vbKeyReturn=13). On a single record form, the "AfterUpdate" event DOES NOT fire UNTIL the text box looses the focus either by pressing the Tab key or otherwise clicking somewhere else on the form.

    You asked: "why not just use the format property on the control?" "FmtPhoneNos" functionality includes automatic area code resolution and enforcement for the region in which the app is executing.

    I'm now trying to understand why it is that after a number has been entered and the "KeyDown" event "keycode" is 13(vbKeyReturn) fires that "Not IsNull(tbPhone) = True"? (As observed in Debug) As mentioned in the original posting, after the "Enter" key is pressed the text box is cleared.

    Code:
    Private Sub tbPhone_KeyDown(KeyCode As Integer, Shift As Integer)
         If KeyCode = vbKeyReturn Then Call tbPhone_AfterUpdate
    End Sub
    
    Private Sub tbCell_AfterUpdate()
         If Not IsNull(Me.tbPhone) Then Me.tbPhone = FmtPhoneNos(Me.tbPhone)
    End Sub

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I say it disappears because you either have the db enter key property set to 'new line' and the control enter key property set to default, OR for this control you have it set to new line. So you are doing a line feed/carriage return in the control on enter key press, which means focus has not left the control until you click or tab out of it. That is also why the control is not null on the key down event. Then again, I've been wrong too many times before...
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    I need to explore your thoughts. Where is "db enter key property set to 'new line' " property set? I tested your thought and found that after the "number entered disappeared" that pressing the "up" scroll key that the number re-appeared.

  6. #6
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Well, you're not wrong.................. this time The control itself had the "Enter Key Behavior" set to "New line in field". Is there another setting at the DB level as well?

  7. #7
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Can't recall for sure with your version (2003) but in 2007, you click the Office Button at the top left and go to Access Options > Move After Enter. Pretty sure that's how you set the default for which all controls that can respond to the enter key this way, except for things like command buttons. For those which you don't want to follow that setting, you set the property to New Line in Field.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,919
    Got it! My DB default is "Move to next field". With having set the "Enter Key Behavior" to default in the offending control(s), the issue is resolved.

    I think the biggest lesson here is to be careful in the future when copying controls within a form or from one form to another without expecting the properties thoroughly.

    Thanks,
    Bill

Please reply to this thread with any new information or opinions.

Similar Threads

  1. OnClick not firing
    By richard1941 in forum Access
    Replies: 4
    Last Post: 01-06-2015, 05:27 PM
  2. Subform events do not seem to be firing
    By mantooth29 in forum Programming
    Replies: 2
    Last Post: 12-12-2013, 03:13 PM
  3. combo box - requery not firing
    By moona in forum Forms
    Replies: 12
    Last Post: 04-20-2013, 06:22 PM
  4. Replies: 5
    Last Post: 03-02-2012, 04:43 PM
  5. AfterUpdate not firing
    By newvb in forum Forms
    Replies: 4
    Last Post: 09-29-2011, 04:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums