• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 536
  • Last Modified:

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

1 Solution
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.
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,

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now