Help...why is my dlookup not working....?

yhchen

Registered User.
Local time
Yesterday, 19:49
Joined
Jul 6, 2008
Messages
63
I have looked at the text book and checked many times, and I am sure I am doing something wrong.... I even created a simple form just to test it out and it is still not working....

can anyone see the mistake in the attached graphic? :(:(:(

sampleu.jpg
 
Last edited:
Try changing your Dlookup to

DLookup("Student_name","[Ticketing Data]","Student_number= " & Forms!Form111!Student_number)
 
Try changing your Dlookup to

DLookup("Student_name","[Ticketing Data]","Student_number= " & Forms!Form111!Student_number)

Thank you Rabbie

Now the error message is gone but returns with #Name?

what does this mean??
 
What was the error message you were getting originally?
 
Since you are refrencing a field in the current form, just refrence it by it's name. (I asume the textbox is named "student_number")

Code:
DLookup("Student_name","[Ticketing Data]","Student_number= " & [Student_number])


As you see it can be a bit abigious so for the future try and name formcontrols diffrent than fieldnames in tables. txtStudentName would be better here.

JR
 
Since you are refrencing a field in the current form, just refrence it by it's name. (I asume the textbox is named "student_number")

Code:
DLookup("Student_name","[Ticketing Data]","Student_number= " & [Student_number])
As you see it can be a bit abigious so for the future try and name formcontrols diffrent than fieldnames in tables. txtStudentName would be better here.

JR

oh...it's still showing #Name?
62.gif


1875cee9.gif
 
Is you controlsource like this:

Code:
DLookup("Student_name","[Ticketing Data]","Student_number= " & [Student_number])

Or like this:

Code:
[COLOR=red]=[/COLOR]DLookup("Student_name","[Ticketing Data]","Student_number= " & [Student_number])

If the former put " = " first

JR
 
JR is right; Dlookup() is very picky about having a space before and after the equal sign!

Access reads this

"Student_number= " & [Student_number]

as being

Student_number= 8

which makes no sense to it. If you actually typed in

Student_number= 8

in the VBA code module, Access would correct it to

Student_number = 8

with the space between Student_number and the equal sign and everything would be cool. But since it lies within the quotation marks, Access reads it literally, as written.
 
Thank you all for the help but for the unknown reason it is still not working.

but since JR has provided another solution in the VBA code area, I will go for the copy and paste and revisit this issue later.

Thanks again for all the help that you guys provided. love you all!!
 

Users who are viewing this thread

Back
Top Bottom