Problems with Code

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
 
M

Mark A. Sam

What is the problem or error you are getting? One think you could try is
eliminiate the prefix Me. from the field references and the suffixes
..Value. So

Me.cboLogin.Value
would become
cboLogin

I don't know if that is a problem, but it won't hurt to test by removing
these. If you could paste the error or decribe the problem a little better
it would help.

God Bless,

Mark A. Sam
 

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