dlookup function

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

samotek via AccessMonster.com

want to look up in the table products and find the code but only for those
products where the supplier id is 2. My working function is :
=DLookUp("grossprice";"products";"Code=" &
Code:
)
How can i attach this condition?
 
S

Stuart McCall

samotek via AccessMonster.com said:
want to look up in the table products and find the code but only for those
products where the supplier id is 2. My working function is :
=DLookUp("grossprice";"products";"Code=" &
Code:
)
How can i attach this condition?
[/QUOTE]

Dim strCriteria As String

strCriteria = "Code=" & [Code] & " And SupplierId=2"
=DLookUp("grossprice", "products", strCriteria)

Change SupplierId to the actual name of your field.
 
B

BruceM via AccessMonster.com

DLookup will return only the first instance that meets the criteria, not a
list. For a list, a form/subform would be the way to go. Another choice
would be a query.

Stuart said:
want to look up in the table products and find the code but only for those
products where the supplier id is 2. My working function is :
=DLookUp("grossprice";"products";"Code=" &
Code:
)
How can i attach this condition?[/QUOTE]

Dim strCriteria As String

strCriteria = "Code=" & [Code] & " And SupplierId=2"
=DLookUp("grossprice", "products", strCriteria)

Change SupplierId to the actual name of your field.[/QUOTE]
 
R

ryguy7272

So you want to see 'only for those products where the supplier id is 2'
Check this out:
http://www.techonthenet.com/access/subforms/link.php

Here's a video tutorial in pre-2007:

Here's a video tutorial in 2007:


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


BruceM via AccessMonster.com said:
DLookup will return only the first instance that meets the criteria, not a
list. For a list, a form/subform would be the way to go. Another choice
would be a query.

Stuart said:
want to look up in the table products and find the code but only for those
products where the supplier id is 2. My working function is :
=DLookUp("grossprice";"products";"Code=" &
Code:
)
How can i attach this condition?[/QUOTE]

Dim strCriteria As String

strCriteria = "Code=" & [Code] & " And SupplierId=2"
=DLookUp("grossprice", "products", strCriteria)

Change SupplierId to the actual name of your field.[/QUOTE]

--

http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/201004/1

.
[/QUOTE]
 

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