MS-Access 2003 Cursor Control

I'm programming a telephone edit in a MS-Access 2003 form field using VBA. My operating system is XP/Pro. Whenever invalid data is detected I display a MsgBox from the AfterUpdate event explaining the nature of the error. However, when I click "OK" to the MsgBox the cursor advances to the next text box.

Can someone explain how I make the cursor remain in the text box with the invalid data until valid data is entered and the content successfully passes my edit check? Here's my code:

Instead of using the AfterUpdate event, use the BeforeUpdate event, and if your validation tests come up with a
failure, then set the Cancel argument to True. That will cancel the update, and should keep the focus on the
control. To be doubly sure, include a line like this:

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

I tried the BeforeUpdate event and got an error on "txtWorkPhone = Trim(txtWorkPhone)" prior to the function call. I commented out the offending statement and the called procedure doesn't recognize invalid data. What could I be doing wrong?

I found my typo. The BeforeUpdate event is working as you said. Thank you!. Now the cursor remains in the original textbox, but at the end of the field. Is there a way I can make it go to the beginning of the field?

If you want to clear the textbox, you'll have to move your code back to the afterupdate event, as clearing it will fire the beforeupdate event and generate an error as you cannot fire the beforeupdate event from there. You could select all the text like this though :
Me.txtWorkPhone.SelStart = 0
Me.txtWorkPhone.SelLength = Len(Me.txtWorkPhone)

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents. The steps to find the Templates folder path are …

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…

Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers.
Hopes this gives you ideas on visualizing your data in new ways ~
Create a calculated field in a query:
…