Message Box and erroring to field

marnieg

Registered User.
Local time
Today, 12:03
Joined
Jul 21, 2009
Messages
70
I have a form that on the field the user inputs a number. On the
After Update event I have a event procedure that does some testing of the values on the form. If the user gets an error I'm using the MsgBox, but it does not focus back on the field that I indicate and it places the cursor in the next modifiable field there allowing them to by pass the error. Should I be using Msgbox for the error or another technique. Here is an example of one of my errors.

If (Me![bau_last_used] = 0 And Me![bau_first] <> Me![bau_low]) Then
MsgBox "First used must equal low value when Last Used is Zero"
Me.bau_first.SetFocus
Exit Sub

The user gets the MsgBox but the cursor is not set on the field indicated, but the next modifiable field. Therefore they can bypass the error.

Also, if the user has entered a number, but wants to clear the field, what is the key they hit to clear the number. It will not take space as it will fail the edits in the afterupdate event.
 
Marnieg,

I assume you are using the After Update event of the bau_first control. Is that right? Even if the focus was successfully going back to bau_first, this still would not achieve your purpose, as they could still just move on from there without further incident.

You can try using the Before Update event instead, like this:
Code:
   If Me![bau_last_used] = 0 And Me![bau_first] <> Me![bau_low] Then
      Cancel = True
      MsgBox "First used must equal low value when Last Used is Zero"
   End If

if the user has entered a number, but wants to clear the field, what is the key they hit to clear the number?

Esc
 
Thank you for the helpful code and about the ESC key. This solved both my problems. This is a great forum. I always find my answers looking at others posts or receive help from experts. :)
 

Users who are viewing this thread

Back
Top Bottom