Criteria for DLookup

  • Thread starter samotek via AccessMonster.com
  • Start date
S

samotek via AccessMonster.com

On my form i want to build a dlookup control looking for the code in the
query "QryProductSales" with the crieria called code.I have the control code
in the form and i want to look up for the data with the corresponding code in
my query.I have built partly the control but i could not define the criteria,
they should be as follows : where code in the form is equal to the code in
the query. Can you help me ?
My following control has no criteria and cannot work:
="Sales: " & "" & DLookUp("[Bought]";"QryProductSales") where ........?
 
M

Marshall Barton

samotek said:
On my form i want to build a dlookup control looking for the code in the
query "QryProductSales" with the crieria called code.I have the control code
in the form and i want to look up for the data with the corresponding code in
my query.I have built partly the control but i could not define the criteria,
they should be as follows : where code in the form is equal to the code in
the query. Can you help me ?
My following control has no criteria and cannot work:
="Sales: " & "" & DLookUp("[Bought]";"QryProductSales") where ........?


If Code is a number type field in the table, try something
like:

="Sales: " & DLookUp("Bought","QryProductSales", "Code=" &
Code)

If Code is a Text field it would be:

="Sales: " & DLookUp("Bought","QryProductSales", "Code=""" &
Code & """")
 
S

samotek via AccessMonster.com

Thank you very much!! It works excellent !!!!!

Marshall said:
On my form i want to build a dlookup control looking for the code in the
query "QryProductSales" with the crieria called code.I have the control code
[quoted text clipped - 4 lines]
My following control has no criteria and cannot work:
="Sales: " & "" & DLookUp("[Bought]";"QryProductSales") where ........?

If Code is a number type field in the table, try something
like:

="Sales: " & DLookUp("Bought","QryProductSales", "Code=" &
Code)

If Code is a Text field it would be:

="Sales: " & DLookUp("Bought","QryProductSales", "Code=""" &
Code & """")
 
M

MsPaula

Marshall, THANK YOU. I, too, found this very helpful. I needed to look up
first and last name so teh User could recognize whether a duplicate already
existed (but not prevent their entry). Expanding on your code worked
perfectly. THANKS!
Paula

Marshall said:
On my form i want to build a dlookup control looking for the code in the
query "QryProductSales" with the crieria called code.I have the control code
[quoted text clipped - 4 lines]
My following control has no criteria and cannot work:
="Sales: " & "" & DLookUp("[Bought]";"QryProductSales") where ........?

If Code is a number type field in the table, try something
like:

="Sales: " & DLookUp("Bought","QryProductSales", "Code=" &
Code)

If Code is a Text field it would be:

="Sales: " & DLookUp("Bought","QryProductSales", "Code=""" &
Code & """")
 
M

Marshall Barton

Wow! A twofor ;-)

Nice to hear that you could adapt it to your needs.
--
Marsh
MVP [MS Access]

Marshall, THANK YOU. I, too, found this very helpful. I needed to look up
first and last name so teh User could recognize whether a duplicate already
existed (but not prevent their entry). Expanding on your code worked
perfectly. THANKS!

Marshall said:
On my form i want to build a dlookup control looking for the code in the
query "QryProductSales" with the crieria called code.I have the control code
[quoted text clipped - 4 lines]
My following control has no criteria and cannot work:
="Sales: " & "" & DLookUp("[Bought]";"QryProductSales") where ........?

If Code is a number type field in the table, try something
like:

="Sales: " & DLookUp("Bought","QryProductSales", "Code=" &
Code)

If Code is a Text field it would be:

="Sales: " & DLookUp("Bought","QryProductSales", "Code=""" &
Code & """")
 

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