Error using Dlookup function

Hi, I need to be refreshed a text box which is based on a result of the query where I hit the Combo from the partner name i have to store a Bill to ID and Customer Name, but on the combo i only return a bill to ID, I thnik the best way to store the Customer name would  be on a text field protected or hidden, i place this code on source for the property of text box but I got an error.
also, everytime when i change the partner name, i use an event after update in order to be requery the text box.

=DLookUp("[Customer Name]","qryPartnerName","[Bill to ID]=Forms!frmReports!cboPartner")

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Does the combobox cboPartner include the Customer Name as one of the fields in your list, if so then you do not need to do a DLOOKUP() you can say (I have used 3 as an example and the columns are numbered from 0


Cheers, Andrew
gfrancoAuthor Commented:
Got it, but I need to use 2 more parameters Bill to ID and Customer Name
The combo only store the Bill TO id, how can I refernece on the combo  (see data for combo)
and also see the property for it.

I tought if  i am using a hiding text field i could send by parameters too or if there any other simple way.

It looks like the problem you have is syntax. Try:

=DLookUp("[Customer Name]","qryPartnerName","[Bill to ID]= " & Forms!frmReports!cboPartner)

You have to exclude the reference to the form object from the quotation marks.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
A Combo box can have only one Bound field (which in this case is Bill to ID).

However, you can reference various other fields from the query providing they're included in the combo box information.

The attached picture shows the Format properties of a combo box that is referring to 6 fields within a query.  The combo box itself only displays the first two fields as the other 4 are hidden from view by entering 0cm in the column widths property.  Various other controls on my form are obtaining their information from one or more of these '0cm' fields within the combo box.  To refer to these columns you must count from zero rather than 1.

So, in your case, to refer to the Customer Name within cboPartner, you'd enter =cboPartner.Column(2) in the textbox's control source.  If you'd like the textbox to refer to more than one field (perhaps Customer Name and Customer), you'd enter =cboPartner.Column(2) & ", " & cboPartner.Column(0).  This second example is assuming that the information is to be displayed on your form.

Hope this helps,
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.