Text Box Validation Rule

  • Thread starter Thread starter cga1982
  • Start date Start date
C

cga1982

I have a text box (for a password) with a validation rule that checks
this password against another text box on the form and either lets you
continue or tells you that the password is incorrect and that you have
to try again.
The problem is that I can just tab right through this text box control.

If I type something in the text box it then does make the validation
check but I can still just tab past it without entering a thing.
Any ideas on how to make Access check the text box even if someone just

tabs past it?
Thanks for your help.
 
cga,
I think when you put ur validation code in "change", or even lostfocus
event should force the code to check ur password.
 
In the Open event of the form:
Me.txtPassword.SetFocus
Or make it the first control in the Tab Order.
(This is necessary so that a user cannot tab around this control)

In the Exit event of the password textbox:
If IsNull(Me.Text9) Or Me.Text9 = "" Then
MsgBox "Gota have a password"
Cancel = True
End If
 
Klatuu, that worked great! Thanks a lot.

Jeff, I would have thought the same thing but I was still able to just
tab over the thing. Thanks.
 
Glad it worked for you.

Jeff, I would not recommend the Change event. It fires for every keystroke.
Also, my first thought was the Lost Focus; however, it does not have a
Cancel capability, and you can neither Set Focus to do a GotoControl If the
control you are trying to go to is the active control.
 
Back
Top