I guess this is a silly question, but I’m having problems figuring this out.
I have two tables with loads of information used to make reports.
I have a query that joins these two tables.
The same query adds two simple filters: A date range and an ID checker.
The reports are supposed to be printed withing a date range with a specific ID.
Every time I need to change the query data range I need to manually edit it and change the parameters.
How can I make a form and pass this information to the query so I won’t have to manually update the query every week?
I made a new form with two date fields and I would need some code to pass this information to the query before opening it, but DoCmd.OpenQuery Method doesn’t permit I pass any information.
Ideally I’d prefer to use a SQL command to set the query and then open it, is this even possible?
Actually, I am using this method often:
Declare variables in a Module and write a function for each one that simply returns the value. You can then use the function call within the Query-Designer (e. g. criteria =
Between getMyValue1() AND getMyValue2())You can then set the global variables before opening the query.
(This has worked better for me than Query-Parameters or direct references to form fields within queries.)