Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto Exit Of A Field

Status
Not open for further replies.

gator9

Technical User
May 17, 2002
162
US
Have a question, the code below is for when a user clicks this field they have to enter a password and if it is incorrect it doesn't let them in. This code works on other apps and works good here but it does let them go into the field is there a way to have it auto exit after there access is denied?

Private Sub Adjustment_Enter()
If InputBox("Please enter your password") = "kjh" Then
Else
MsgBox "Incorrect Password"
'Would like to have the exit code here?

End
End If
End Sub

Sincerely,

Charles
 
Take a look at the SetFocus method or at the DoCmd.Close method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
After your mesage box try

MeOtherFieldonForm.SetFocus
Me.Adjustment.Enabled = False


The reason for the set focus is I don't know if you can 'disable' a field if it has the focus.
 
I misread your original post. Go with PHV's answer to close the form. My answer will leave the form open but 'disable' the field.
 
Works great thanks guys!

Private Sub Adjustment_Enter()
If InputBox("Please enter your password") = "kjh" Then
Else
MsgBox "Incorrect Password"
Me.Page2button.SetFocus

End
End If
End Sub

Sincerely,

Charles
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top