DLookUp

kbreiss

Registered User.
Local time
Today, 21:29
Joined
Oct 1, 2002
Messages
228
Hello,
I have a combo box that hides the primary id and displays the Facility Name.
When a facility name is clicked on I would like for it to automatically look up the facility manager. Here is the DLookUp code that I am running now, but nothing is happening.


=DLookUp("[MANAGER]","[FACILITY]","[FAC_ID] = [Forms]![Appointment]![COMBO12]")

Does anyone have any idea how looking up the facility manager could be acheived.

Thanks in advance,

Kacy
________
HONDA CB1000
 
Last edited:
It won't reference your combobox if you refer to it within the Criteria string.

=DLookUp("[MANAGER]","[FACILITY]","[FAC_ID] = " & [Forms]![Appointment]![COMBO12])
 
I tried to do a requery macro on the AfterUpdate and it seems to work. Is this method allright? Also when I tried the code you gave me I received an #error. Thanks for the advice.

Kacy
________
SC2 REPLEYS
 
Last edited:
Can't you just include the Facility Manager as the third column (hidden) in your combo box and then reference the column....

=[como12].Column(2)

Note, column values start at 0.

You should also rename your combo box to something more descriptive like 'cboFacilityID'. Makes debugging MUCH easier.

so...

=[cboFacilityID].Column(2)

Another tip...DLookUp is notoriously slow and should be used sparingly. You'll find my example MUCH faster.

The 'FindFirst' method is another faster option but requires some vba skills.
 

Users who are viewing this thread

Back
Top Bottom