DLookup Help anyone ?

traversd

Board Regular
Joined
Mar 17, 2002
Messages
82
Hi,

I have a form called Opportunity_Table1, that has a Combo Box called Contact Name, which gives a list of customer in the table "Customer_Table"

I want to automatically display the company name, depending on which Contact is selected in "Contact name" in the txt field "Company"

Does anyone know of the syntax I need to use ? I have been wrestling with DLookup to keep getting an #Error? Message !

Thanks
Darren
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
A bit more information is needed. Are Contact and Company Name in the same table?

The basic way to do this is to put code in the AfterUpdate event of the ComboBox. So something like:
Code:
Private Sub Contact_Name_AfterUpdate()
    Me.txtCompany = DLOOKUP("[Company Name]","Customer_Table" _
        ,"[Contact Name] = '" & Me.Contact_Name.Value & "'"
End Sub
But if the Contact Name (or customer - you've confused me a little here) and Company Name are not in the same table, then you'll need to refer to a query instead of "Customer_Table".

Hope this helps,

Russell
 
Upvote 0

Forum statistics

Threads
1,221,574
Messages
6,160,602
Members
451,657
Latest member
Ang24

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