Would like to run a query that is using a field in a table for it's criteria

Status
Not open for further replies.

AnsonniChu

New member
Local time
Yesterday, 21:18
Joined
Jul 11, 2019
Messages
2
I am new and have very basic knowledge of programming.

So, I have a table that contains fields that is written in the same way as you would write in a criteria for a field in a query
(ex: the field would contain:
"1234 Or 1242"
or some date range:
"Between #06/23/2019# and #06/25/2019#").

I would like to setup an event that runs a query with the field in the table as the criteria and loop it so it runs the query for each line.

Please if someone can help me with this it is appreciated.
 
Welcome.
Suggest you give us a little more info. You don't see fields in tables with value "1234 Or 1242".
Table name
Field name
Field value
An overview of what you are trying to accomplish in plain English.
 
Hi. Welcome to the forum. The only thing I could think of at the moment is to use a "dummy" query and then modify its SQL adding the criteria from the table as you loop through it and run each one. You do this using a QueryDef object.
 
Sorry I'll try to explain i have a table like below:

ID PromoDept Periods
1 1267 OR 1415 Between #06/23/2019# and #06/29/2019#
2 1536 OR 6538 OR 1415 Between #06/23/2019# and #06/25/2019#
3 2353 OR 2356 Between #06/26/2019# and #06/27/2019#
4 2366 OR 2356 Between #06/26/2019# and #06/27/2019#

And I would like to setup a macro that essentially looks at each line individually and use Field PromoDept as a criteria for a query. I attached an example database don't know if that would help?
 

Attachments

see this demo and try to understand the code.
 

Attachments

Status
Not open for further replies.

Users who are viewing this thread

Back
Top Bottom