DLookUp in criteria

  • Thread starter Thread starter JIM.H.
  • Start date Start date
J

JIM.H.

Hello,
I checked the result of this command: DLookUp
("[myPar]", "[myTable]") is "'AT','BT','CT'" and I need to
use this formula in the criteria of the query I define
as "IN (DLookUp("[myPar]", "[myTable]"))". But it does not
seem working in the query. Am I allowed to do this? If
not, how can I dynamically change the criteria of a query?
Thanks,
Jim.
 
Hello,
I checked the result of this command: DLookUp
("[myPar]", "[myTable]") is "'AT','BT','CT'" and I need to
use this formula in the criteria of the query I define
as "IN (DLookUp("[myPar]", "[myTable]"))". But it does not
seem working in the query. Am I allowed to do this?

No. Storing three values in a single field as you're doing is never
appropriate!
If not, how can I dynamically change the criteria of a query?

A couple of ways -

WHERE InStr([myfield], DLookUp("[MyPar]", "MyTable")) > 0

will do a sort of "inverted" search, looking for the value of the
field somewhere within your parameter; or, by using the value from
MyPar in VBA code to construct the SQL text of a query.
 

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

select top 5 4
Dlookup in Query 2
Use In() Expression as Query criteria with guts from Function 1
Dlookup 5
Setting a Month Criteria 9
Access Dcount (multiple criteria) 3
Conditional Criteria 4
Help to correct this DLookUp 3

Back
Top