dlookup using multiple fields

G

Guest

I am looking for ideas that can help me lookup a value in a table
(tblcustomer) that is based on mutilple fields. Here is an example, an user
will manually enter a bank#,account# and the note# on a form that I created,
and what I want this form to do is return the customer name in a text box by
going to an existing table (tblcustomer) using the combination of Bank#,
Account# and note #. TblCustomer contains these fields: bank#,account#,
note#, Customer name and Customer address. I can do a simple dlookup based on
one single field say just account#, but I don't know how to do a dlookup
based on 3 fields combine. Is CONCATENATING all three fields the best way to
go, or is there any other way I can use that is more efficient. Any help is
very much appreciated.
 
A

Allen Browne

Lisa, for the 3rd argument of DLookup(), you need to supply a string that
looks like the WHERE clause of a query, e.g.:
"([bank#] = 99") AND ([account#] = 88) AND ([note#] = 77)"

To get that result, you will usually be concatenating the values into the
string.

Don't forget to use quotes marks as delimiters if the field is of type Text,
or # as delimiters around date values.
 
G

Guest

A dlookup using few fields in a filter will be writen as follow

=Dlookup("FieldName","TableName","[FieldNumber] = " & Me.FieldNum & " And
[FieldString] = '" & me.FieldStr & "' AND [FieldDate] = #" & me.FieldDate &
"#")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Dlookup 6
DLookUp 1
Dlookup and Conditional Formatting 3
DLookUp 2
Total in subform 9
dlookup 4
Dlookup error 4
YES/NO FIELD IN COMBOBOX 6

Top