Authenticate password on pressing enterr

ekta

Registered User.
Local time
Today, 09:32
Joined
Sep 6, 2002
Messages
160
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
 
You can always make life easier on yourself.

Goto the properties of the Button. Set the "Default" property to true.


Setting this property to True will allow "keyboarders" to just press the Enter Key and the OnClick event will fire. Of course this means they can't use the enter key to move from the User Name to the Password field.
 
:) Thanks
 

Users who are viewing this thread

Back
Top Bottom