How can I establish two criterias in DLookup function

A

AndyEduardo

Thanks to Allen Browne for his help.

I need help again.

I used DLookup function, as said Allen Browne, and it was very useful

The point now is as follow.

DLookup (-expression, domain, [criteria]-)

I don't have problem with -expression and domain- but wiht [criteria]
have one problem. As you know I select the client in the Form's Combo
then in the cbo of subform Invoice's Details shows the products b
agreement, subsequently I put the price, it can be different in th
future for each client, and for this reason this price is not relate
with the price of agreement.

The problem now in this..... I used DLookup function but frecuently th
same product can be sold to many clients, then DLookup look for th
first record in the table or querie (domain), then I need to establis
two criterias in DLookup (ProductID,ClientID)...

Can I select two criterias in DLookup function? How can I do that?

I tried but Access said Error 13.... what can I do?

Thanks for your help
 
A

Allen Browne

The 3rd argument in DLookup() can be anything you put in the WHERE clause of
a query, so you coud do this kind of thing:

Dim strWhere As String
strWhere = "(ProductID = 9) AND (ClientID = 4)"
Debug.Print DLookup("SomeField", "SomeTable", strWhere)

If you are trying to concatenate the value from a control on your form into
the string:
strWhere = "(ProductID = " & [txtProductID] & ") AND (ClientID = " &
[txtClientID] & ")"

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 

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

Top