PC Review


Reply
Thread Tools Rate Thread

DLookup with 2 filter criteria

 
 
jenni_p
Guest
Posts: n/a
 
      29th Jun 2004
Hello -
Is it possible to write a DLookup with 2 filter criteria?

For example, I have a query set up which places my
products in "categories" based on 2 variables
1) Destination_id
2) Product_Id

So when a user creates a purchase order, I want the
category to automatically pop up based on the destination
and product selected.

So here is where I am stuck;

Dim strfilter As String

strfilter = ????????????????????

Me!CategoryName = DLookup("Category", "qry_categories",
strfilter)

Any ideas?

Thanks in advance for the help!
Jenni
 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      29th Jun 2004
Try:

strfilter = "Destination_id = " & Destination_id & " and
Product_ID = " & Product_id

>-----Original Message-----
>Hello -
>Is it possible to write a DLookup with 2 filter criteria?
>
>For example, I have a query set up which places my
>products in "categories" based on 2 variables
>1) Destination_id
>2) Product_Id
>
>So when a user creates a purchase order, I want the
>category to automatically pop up based on the destination
>and product selected.
>
>So here is where I am stuck;
>
>Dim strfilter As String
>
>strfilter = ????????????????????
>
>Me!CategoryName = DLookup("Category", "qry_categories",
>strfilter)
>
>Any ideas?
>
>Thanks in advance for the help!
>Jenni
>.
>

 
Reply With Quote
 
John Vinson
Guest
Posts: n/a
 
      29th Jun 2004
On Tue, 29 Jun 2004 08:11:42 -0700, "jenni_p"
<(E-Mail Removed)> wrote:

>Hello -
>Is it possible to write a DLookup with 2 filter criteria?


Only one filter criterion - but it can be essentially as complicated
as you wish. The third argument to any of the domain functions should
be a text string which is a valid SQL query WHERE clause, without the
word WHERE - and it can have ANDs, ORs, LIKE, or any query operator
you'ld use in a query.

>For example, I have a query set up which places my
>products in "categories" based on 2 variables
>1) Destination_id
>2) Product_Id
>
>So when a user creates a purchase order, I want the
>category to automatically pop up based on the destination
>and product selected.


strfilter = "[Destination_ID] = " & Me!txtDestination _
& " AND [ProductID] = " & Me!txtProduct

Given arbitrary values in the form controls, this would end up

[Destination_ID] = 31 AND [ProductID] = 882

Note that blanks are important - for instance, there must be blanks on
both sides of the word AND, otherwise your string ends up like

[DestinationID] = 31AND ...


John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
two criteria in DLookup Song Su Microsoft Access Queries 5 7th Mar 2010 12:54 AM
Help with DLookup Criteria MarieM via AccessMonster.com Microsoft Access Reports 4 24th Jan 2007 02:35 PM
DLookUp with 2 criteria =?Utf-8?B?bmVlbm1hcmll?= Microsoft Access Form Coding 2 23rd Aug 2006 02:09 PM
DLookUp with two criteria Tim Microsoft Access Form Coding 1 9th Sep 2004 05:29 PM
DLookUp in criteria JIM.H. Microsoft Access Queries 1 25th Nov 2003 12:37 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:41 PM.