Nov 21 2005, 05:44 PM
I have searched for days and not been able to find an answer to a supposedly easy question.
I have a continuous form "Entry_Form" based off a table called "Today". I want to add additional criteria to the table using the form and have created a combo box that is based on a separate table called "Reason_Codes". "Reason Codes" has two fields "ID" and "Description".
When selecting the combo box "ID_Selector" I populate one of the fields on the form which then populates the corresponding field on the table. This works.
My problem is that I want to have a text box on the form called "Description_Code" populated automatically the "Description" based the ID chosen.
I have created the following DLookUp equation and placed it into the Control Source, but nothing is populated in the "Description_Code" field.
=DLookUp("[Description]","[Reason_Codes]","[ID] = Forms![Entry_Form]!ID_Selector")
Needless to say, I have tried dozens of varieties, but to no avail. Is DLookUp the proper function? What am I doing wrong?
Any help would be greatly appreciated.
Nov 21 2005, 05:50 PM
=DLookUp("[Description]","[Reason_Codes]","[ID]=" & Forms![Entry_Form]!ID_Selector)
Note that if your ID field is TEXT, rather than numeric, you will need:
=DLookUp("[Description]","[Reason_Codes]","[ID]='" & Forms![Entry_Form]!ID_Selector & "'")
Nov 21 2005, 06:03 PM
Unfortunately that did not work. It gives the #Name? operator expression.
Nov 21 2005, 06:10 PM
The syntax is correct for the controlsource of a control (and for a Dlookup), so we need to figure out why it isn't working in your form.
If you hard-code in an ID, does it return a value? For example:
(assuming 1 is a valid ID). If so, we need to look at the Forms![Entry_Form]!ID_Selector portion. Is the form open? Is the spelling all correct?
Honestly, if you already have a combo box to pull the ID, it might be a lot simpler to simply add the Description column to your combo box and have it display both columns (although remaining bound to only the ID column).
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here