Text Box Validation Rule

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.
 
G

Guest

cga,
I think when you put ur validation code in "change", or even lostfocus
event should force the code to check ur password.
 
G

Guest

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
 
C

cga1982

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top