DLookup #Name? error

bthomas

Board Regular
Joined
Mar 4, 2008
Messages
139
I'm lost. :confused:

I am trying to create a form that automatically fills a field from a lookup table based on the criteria in another field.

The criteria field is called ExceptionCode and the autofill field is called PRASE. The lookup table is named 04LookupExceptionCode. The form name is Administrative-AccountRolodex_ExceptionCodesSubform.

My code is.

Code:
[FONT=Times New Roman]DLookup("[PRASE]", "04LookupExceptionCode", "[ExceptionCode] =  "& Forms![Administrative-AccountRolodex_ExceptionCodesSubform]![ExceptionCode])<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>[/FONT]

When I toggle to form view the autofill field returns #Name?. What am I doing wrong. :(

Thanks in advance!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Is the Dlookup located on the main form or on the subform you are referring to?

Alan
 
Upvote 0
Hi alansidman,

Thanks for responding.

It is in the subform. I haven't even tested it in the main form yet.
 
Upvote 0
"[ExceptionCode] = "& Forms![Administrative-AccountRolodex_ExceptionCodesSubform]![ExceptionCode])

I don't see a space between the second quote and ampersand above. That's a problem, probably.

If the DLookup Function is in the subform itself I think you can just use (because its the same container object):
"[ExceptionCode] = " & [ExceptionCode]

If ExceptionCode is not numeric (if it is text) you need quotes:
"[ExceptionCode] = '" & [ExceptionCode] & "'"

All just guesses on my part. Maybe it's something else! Trial and error should get you there. If you have now actually put this "subform" in a main form then that might change things...

(Note that many databases require a letter or an underscore as the first character of a table name. You may want to avoid tables starting with numbers to make your project more scalable).
 
Last edited:
Upvote 0
Thank you! I will try this. Also, thanks for the tip. I did not know that about the table names.
 
Upvote 0

Forum statistics

Threads
1,216,971
Messages
6,133,813
Members
449,835
Latest member
vietoonet

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top