Hi:
I am using the code below on the OnClick event of a button to check if the user entered the correct password. Right now the user has to click on the OK button. I want to run the same code when user presses the ENTER key after entering the password. Because some users do not want to click on the button.
I entered this code on Lost Focus but did not work. Do I have to change something in the code to make this work
Private Sub CmdAuthenticate_Click()
If DLookup("[Password]", "N_tblPassword", _
"[USERID] = [Forms]![N_frmLogon]![txtUSERID]") = [Forms]![N_frmLogon]![txtPassword] Then
'strUserLevel = UserLevel
MsgBox "Your password has been authenticated!"
DoCmd.OpenForm "aaafrmMain"
DoCmd.SetWarnings False
DoCmd.OpenQuery "N_qappLocalUser"
DoCmd.SetWarnings True
DoCmd.Close acForm, "N_frmLogon"
ElseIf IsNull(txtUSERID) Then
MsgBox "The USER ID field cannot be blank. Please type your USER ID"
DoCmd.GoToControl "txtUSERID"
ElseIf IsNull(txtPassword) Then
MsgBox "The password field cannot be blank. Please type your password."
DoCmd.GoToControl "txtPassword"
Else
MsgBox "Your password is wrong"
DoCmd.GoToControl "txtPassword"
txtPassword.Text = ""
End If
End Sub
Thanx
Ekta
I am using the code below on the OnClick event of a button to check if the user entered the correct password. Right now the user has to click on the OK button. I want to run the same code when user presses the ENTER key after entering the password. Because some users do not want to click on the button.
I entered this code on Lost Focus but did not work. Do I have to change something in the code to make this work
Private Sub CmdAuthenticate_Click()
If DLookup("[Password]", "N_tblPassword", _
"[USERID] = [Forms]![N_frmLogon]![txtUSERID]") = [Forms]![N_frmLogon]![txtPassword] Then
'strUserLevel = UserLevel
MsgBox "Your password has been authenticated!"
DoCmd.OpenForm "aaafrmMain"
DoCmd.SetWarnings False
DoCmd.OpenQuery "N_qappLocalUser"
DoCmd.SetWarnings True
DoCmd.Close acForm, "N_frmLogon"
ElseIf IsNull(txtUSERID) Then
MsgBox "The USER ID field cannot be blank. Please type your USER ID"
DoCmd.GoToControl "txtUSERID"
ElseIf IsNull(txtPassword) Then
MsgBox "The password field cannot be blank. Please type your password."
DoCmd.GoToControl "txtPassword"
Else
MsgBox "Your password is wrong"
DoCmd.GoToControl "txtPassword"
txtPassword.Text = ""
End If
End Sub
Thanx
Ekta