Dlookup (1 Viewer)

benc

Registered User.
Local time
Today, 18:40
Joined
Dec 31, 2001
Messages
57
Hi im trying to get my dlookup code to work but can get it to.

I have create a blank form with a username and password box i have a table called staff in it i have a column called staff password and staffusername and issales(yes/no)

my code is as follows but gives me an error on the dlookup.

getpass = DLookup("StaffPassword", "[staff]", "[StaffUserName] =" & [me.frmusername])
issales = DLookup("[staffissales]", "[staff]" = "Me.frmusername")


If Me.frmpassword <> getpass Then
MsgBox "Your Username or password is incorrect. Access Denied"
Me.frmpassword = ""
Me.frmpassword.SetFocus
Exit Sub
End If

If issales = True Then

Dim userform As String
Dim stLinkCriteria1 As String

userform = "Sales main menu"
DoCmd.Close acForm, "[login]", acSaveYes
'Close Form
'acSaveYes saves any changes to the form without prompting
DoCmd.openform userform, , , stLinkCriteria1
 

DBL

Registered User.
Local time
Today, 18:40
Joined
Feb 20, 2002
Messages
659
Try

getpass = DLookup("StaffPassword", "[staff]", "[StaffUserName] ='" & [me.frmusername]& "'")
issales = DLookup("[staffissales]", "[staff]", "[staffusername]='" & Me.[frmusername]"'")


You need to specify '" because it's a text string rather than an integer
 

Users who are viewing this thread

Top Bottom