dlookup

plonker

Registered User.
Local time
Today, 11:45
Joined
Mar 14, 2003
Messages
19
i have a problem with DLookup:

strPassword = DLookup("[Password]", "tblEmployee", "[First_Name] = cboUserName")

i am trying to match the password entered in a textbox with that of the password in the database (First_Name)

i get an error: invalid use of null
 
Code:
strPassword = DLookup("[Password]", "tblEmployee", "[First_Name] = '" & Me.cboUserName & "'")
 
try

strPassword = DLookup("[Password]", "tblEmployee", "[First_Name] = " & Forms!FormName!cboUserName)
 
Code:
strPassword = DLookup("[Password]", "tblEmployee", "[First_Name] = '" & Me.cboUserName & "'")

still get an invalid use of null

Code:
strPassword = DLookup("[Password]", "tblEmployee", "[First_Name] = " & Forms!Main_Screen!cboUserName)

how do you reference the formname?

my form's name is main screen but it cant find it? am i referencing it correctly?
 
Have a look at this and save it for in the future.

Andy
 

Attachments

Try this firstly:

Msgbox Nz(DLookup("[Password]", "tblEmployee", "[First_Name] = '" & Forms!Main_Screen!cboUserName & "'"),"Null Value - Not found.")

This will give you a message box to say what the DLookup returns - if it finds a value it'll message it to you, if there is no value you'll get a message box saying "Null Value - Not found."
 
mile - it cant find the form main screen...i've checked the name in the vba property window and it refers to it as Form_Main Screen. Now i've referenced that and that doesnt work either - it throws a syntax error
 
Forms![Main_Screen]!cboUserName


P.S. Have a look at this thread and begin to realise why you shouldn't put spaces or symbols into your control and object names.
 
:) that's one for the future anyway

i got your message working but it returns the value not found

when i made the change to my code i got an error in string in query expression '[First_Name] ='ST101'
which is the employee id for the employee whose name i've selected in the combo?


Got it - mile thanks for your help! i wouldnt have found the error only for your msgbox - my syntax was messed up - thanks again - sorry if i was a pain in the ass

plonker
 
Last edited:
i have the user id as a separate field and it contains a number - the dlookup seemed to be returning the employee id rather than the name, which i was looking for - it turned out to be a syntax error...
 

Users who are viewing this thread

Back
Top Bottom