"msgbox" response problem

  • Thread starter Thread starter David##
  • Start date Start date
D

David##

I have a routine that validates data. If VALID, nothing
happens. If INVALID, I have a vbOKOnly msgbox stating the
error. After the msg displays, I want to set focus back to
the field with the bad data. Instead, focus goes to the
next field regardless of where I stick a "SetFocus"
command. How do I direct to the bad field without
depending on the user to go there?
 
David## said:
I have a routine that validates data. If VALID, nothing
happens. If INVALID, I have a vbOKOnly msgbox stating the
error. After the msg displays, I want to set focus back to
the field with the bad data. Instead, focus goes to the
next field regardless of where I stick a "SetFocus"
command. How do I direct to the bad field without
depending on the user to go there?

This code should be run in the BeforeUpdate event because it has a Cancel
argument which prevents the field from ever losing focus in the first place
thus eliminating the need to set the focus back.

If (SomeTest) = True Then
MsgBox "Try Again"
Cancel = True
Me.NameOfControl.Undo
End If
 
David## said:
I have a routine that validates data. If VALID, nothing
happens. If INVALID, I have a vbOKOnly msgbox stating the
error. After the msg displays, I want to set focus back to
the field with the bad data. Instead, focus goes to the
next field regardless of where I stick a "SetFocus"
command. How do I direct to the bad field without
depending on the user to go there?


Where do you have the routine?

If it's in an AfterUpdate event, move it to the BeforeUpdate
event and instead of using SetFocus use Cancel = True
 
Thanx -
I was sitting in the "Afterupdate" event
-----Original Message-----


This code should be run in the BeforeUpdate event because it has a Cancel
argument which prevents the field from ever losing focus in the first place
thus eliminating the need to set the focus back.

If (SomeTest) = True Then
MsgBox "Try Again"
Cancel = True
Me.NameOfControl.Undo
End If


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


.
 
Thanx - I WAS at "afterupdate"
-----Original Message-----



Where do you have the routine?

If it's in an AfterUpdate event, move it to the BeforeUpdate
event and instead of using SetFocus use Cancel = True
 
Back
Top