#Name error on label

mafhobb

Registered User.
Local time
Today, 06:13
Joined
Feb 28, 2006
Messages
1,249
Hello everyone!

I have a form with a label that has the following code:

Code:
=Nz(DLookUp("EngineerID","Tbl-Users","PKEnginnerID = " & [StrLoginName] & ""),"")

This same code is used in severalplaces to fill out textboxes and table, but for some reason this labell gives me the "#Name?" error

Anybody knows why?

mafhobb
 
are you using the .Caption element?

ie
Me.Label.Caption = ....
 
Also [StrLoginName] is a variable so it does not need [] around it
 
Actually, I was mistaken...it is a textbox modified to look like a label.

The control source for the textbox is set to that code.

I have tried to remove the brackets but they seem to get inserted automatically...

mafhobb
 
Well, I've created a label with an on form load event, and that seems to work.

I am curious to find why the textbox did not.

mafhobb
 
If you type it into the actual propery command line Access will encapsulate it with []. If you do it in vba it does not.
 
If PKEngineerID is a string (text data type) try
Code:
=Nz(DLookUp("EngineerID","Tbl-Users","PKEnginnerID = [COLOR="Red"]'[/COLOR]" & [StrLoginName] & "[COLOR="Red"]'[/COLOR]"),"")

If not a string

Code:
=Nz(DLookUp("EngineerID","Tbl-Users","PKEnginnerID = " & [StrLoginName] & ""),"")
 

Users who are viewing this thread

Back
Top Bottom