G
Guest
I am having problems with a few lines of the code.
I am having problems with the line of code that states:
If Me.txtPassword.Value = DLookup("Password", "Login", "[lngUserID]=" &
Me.cboLogin.Value) Then
lngMyEmpID = Me.cboLogin.Value
and the fact that you are told to place this line of code in a module:
Public lngMyEmpID As Long
I am not familiar with modules so I would appreciate some advice on how to
create one. Additionally, the entire code that was written for the form is
listed below. Perhaps someone else can read it and help me to
understand the If statement that I mentioned above (step by step advice
please)
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboLogin) Or Me.cboLogin = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboLogin.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in Login table to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("Password", "Login", "[lngUserID]=" &
Me.cboLogin.Value) Then
lngMyEmpID = Me.cboLogin.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "frmLogon", acSaveNo
'DoCmd.OpenForm "frmSplash_Screen"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.",
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
I am having problems with the line of code that states:
If Me.txtPassword.Value = DLookup("Password", "Login", "[lngUserID]=" &
Me.cboLogin.Value) Then
lngMyEmpID = Me.cboLogin.Value
and the fact that you are told to place this line of code in a module:
Public lngMyEmpID As Long
I am not familiar with modules so I would appreciate some advice on how to
create one. Additionally, the entire code that was written for the form is
listed below. Perhaps someone else can read it and help me to
understand the If statement that I mentioned above (step by step advice
please)
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboLogin) Or Me.cboLogin = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboLogin.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in Login table to see if this
'matches value chosen in combo box
If Me.txtPassword.Value = DLookup("Password", "Login", "[lngUserID]=" &
Me.cboLogin.Value) Then
lngMyEmpID = Me.cboLogin.Value
'Close logon form and open splash screen
DoCmd.Close acForm, "frmLogon", acSaveNo
'DoCmd.OpenForm "frmSplash_Screen"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.",
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub