AmandaA531
11-01-2017, 05:00 PM
This DLookup has me stumped!
In a form [frm_MCOs], I have 2 fields, [ChangeAnalystApproval], [DocControlPassword]
In a table [tbl_Employees], I have 2 fields [EmployeeName], [Passcode]
I would like the database to compare the fields in [frm_MCOs] form to fields in [tbl_Employees] table like so:
[frm_MCOs]![ChangeAnalystApproval] must equal [tbl_Employees]![EmployeeName]
[frm_MCOs]![DocControlPassword] must equal [tbl_Employees]![Passcode]
If Password is blank, display msgbox1
If Passcode and DocControlPassword match, display the msgbox2
If Passcode doesn’t match DocControlPassword, display msgbox3
It recognizes the "blank" Password but the problem I'm having is that it doesn't seem to be comparing the Passcode and DocControlPassword.
Here is my code:
Private Sub DocControlCheckPassword_Click()
' msgbox1
If IsNull(Me.DocControlPassword.Value) Then
MsgBox "You cannot enter a blank Password. Try again."
Me.DocControlPassword.SetFocus
End If
' msgbox2
If DLookup("Passcode", "tbl_Employees", "EmployeeName='" & Me.DocControlPassword & "'") Then
MsgBox "You have approved this change."
Else
' msgbox3
MsgBox "Password does not match. Please try again."
Me.DocControlPassword.SetFocus
End If
End Sub
In a form [frm_MCOs], I have 2 fields, [ChangeAnalystApproval], [DocControlPassword]
In a table [tbl_Employees], I have 2 fields [EmployeeName], [Passcode]
I would like the database to compare the fields in [frm_MCOs] form to fields in [tbl_Employees] table like so:
[frm_MCOs]![ChangeAnalystApproval] must equal [tbl_Employees]![EmployeeName]
[frm_MCOs]![DocControlPassword] must equal [tbl_Employees]![Passcode]
If Password is blank, display msgbox1
If Passcode and DocControlPassword match, display the msgbox2
If Passcode doesn’t match DocControlPassword, display msgbox3
It recognizes the "blank" Password but the problem I'm having is that it doesn't seem to be comparing the Passcode and DocControlPassword.
Here is my code:
Private Sub DocControlCheckPassword_Click()
' msgbox1
If IsNull(Me.DocControlPassword.Value) Then
MsgBox "You cannot enter a blank Password. Try again."
Me.DocControlPassword.SetFocus
End If
' msgbox2
If DLookup("Passcode", "tbl_Employees", "EmployeeName='" & Me.DocControlPassword & "'") Then
MsgBox "You have approved this change."
Else
' msgbox3
MsgBox "Password does not match. Please try again."
Me.DocControlPassword.SetFocus
End If
End Sub