help with this code does not work urgent!!!!!!!!!!!

T

T3E

hi this code doesn't work the bit where it says:
If Me.txtPassword.Value = DLookup("consultantPassword", "tblconsultant",
"[ConsultantID]=" & Me.Cboconsultant.Value) Then
is apparently incorrect as the message says. i have a combo box called
'cboconsultant', text box called 'txtpassword', command button called 'login'
and the two fields that are used form the consultant table is consultant ID,
consultant
Surname




Private Sub login_Click()
'Check to see if data is entered into the UserName combo box

If IsNull(Me.Cboconsultant) Or Me.Cboconsultant = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.Cboconsultant.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 tblconsultant to see if this
'matches value chosen in combo box

If Me.txtPassword.Value = DLookup("consultantPassword", "tblconsultant",
"[ConsultantID]=" & Me.Cboconsultant.Value) Then

ConsultantID = Me.Cboconsultant.Value

'Close logon form and open splash screen

DoCmd.Close acForm, "Form5", 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

can you help find what is the problem
 
B

BruceM

Is the bound column for cboConsultant a number? If it is text you will need
to do something like this for the DLookup criteria:
"[ConsultantID] = """ & Me.Cboconsultant & """"
 

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