Microsoft Access Dlookup Query
Matthew Optional MeehanMicrosoft Access Dlookup Function
1 Answer
DLookup
to return more than one value. Ms Access 2010 Dlookup Examples
![2010 2010](/uploads/1/2/6/0/126086090/906633568.jpg)
MID
s into a Recordset
, loop through them and append them to Me!MID
:DAO works there as well, you just need a reference to
Microsoft DAO x.x Object Library
.Microsoft Access Dlookup Multiple Values Pdf
Christian SpechtNot the answer you're looking for? Browse other questions tagged ms-accessvbaaccess-vba or ask your own question.
When you design a form in Access, you may want to display a value from a table or query other than the one that your form is bound to. For example, suppose that you have a Products form that is bound to a Products table. After you design the form, however, you decide that you want the form to display the name of the supplier contact for each product — data that resides in a table called Suppliers. The following procedure shows you how to use the DLookup function to accomplish this task. You can alter the expression in step 6 to suit your own data.
Add the text box
- In the Navigation Pane, right-click the form that you want to change, and then click Design View on the shortcut menu.
- On the Design tab, in the Controls group, click Text Box.
- Locate the area in the form in which you want to add the control, and then drag the pointer on the form to create the text box.
- Right-click the text box, and then click Properties on the shortcut menu.
- In the property sheet, click the All tab.
- Set the Control Source property to the following value:=DLookup('[ContactName]','[Suppliers]','[SupplierID]=' & Forms!Products!SupplierID)
- Save your form changes, and then close the property sheet.
This expression searches in the Suppliers table and returns the contact name of the supplier whose supplier ID matches the value in the SupplierID control on the Products form. Note how the & operator is used to construct the third argument of the DLookup function (the third argument is '[SupplierID]=' & Forms!Products!SupplierID). A common error that you should avoid is placing quotation marks around the entire argument instead of around only the text that precedes the & operator.