=DlookUp generating #Error

3link

Board Regular
Joined
Oct 15, 2010
Messages
138
I've tried everything to get this to work. I must be missing some fundamental concept.

I'm attempting to use the DLookup function as an expression in a textbox in a form. I have been placing the following text into the "Control Source" field of the text box.

Code:
=DLookUp("[Status]","Ghost","[Subpoena ID] =" & Forms![Ghost2]!Combo)

Ghost is the name of the table.
Status is the name of the results column on the Ghost table.
Subpoena ID is the name of the value column on the Ghost table.
Ghost2 is the name of the form.
Combo is the name of the dropdown box on the Ghost2 form.

So I basically want the textbox to look up the adjacent column ("Status") of the "Subpoena ID" in the dropdown menu (combo). I am consistently getting a #Error message. Can anyone tell me what I'm doing wrong?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Is your "Subpoena ID" field formatted numeric or text?

If text, you will need to use text qualifiers, as shown here under the section called "Specifying Textual Criteria": http://support.microsoft.com/kb/208786
 
Upvote 0
Is your "Subpoena ID" field formatted numeric or text?

If text, you will need to use text qualifiers, as shown here under the section called "Specifying Textual Criteria": http://support.microsoft.com/kb/208786

Thank you. Subpoena ID is formatted in text.

Just tried this out. I basically took
Code:
   =DLookup("[ContactName]", "[Customers]", _
      "[CustomerID]='" & Forms![Orders]![CustomerID] & "'")

from that source to get:

Code:
=DLookup("[Status]", "[Ghost]", _
      "[Subpoena ID]='" & Forms![Ghost2]![ComboD] & "'")

When I hit enter after putting this into the control source field, I get an error message:

errorjwa.png


I've tried it over and over. My code is identical to the examples (minus the names).
 
Upvote 0
It can be helpful to debug by "asking" the form what's in the combo: put a button on the form and in it's click event the code:

Code:
MsgBox "|" & Forms![Ghost2]![ComboD] & "|"
This should show between two pipes exactly what's in the combobox - so you can check if the criteria you are using is valid.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,748
Members
448,989
Latest member
mariah3

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