how to pass a parameter to a query base of a query that is the base of a report

Joined
Aug 4, 2012
Messages
1
Reaction score
0
Hi

I have a query, called query1, that has a parameter1.
I made another query, called query2 that is based query1.
I then got another query, called query3, which is based on query2, and is this last query, query3 that is the record source of a reportA.

opening the reportA, will cause the parameter value from query1 to be called and when entered I get the expected result. up to that point, all is great! a bit slow, guess due to the query on top of a query but, it works and I couldn't be happier.

Hoping to make the report calling more user friendly, I have created a form so the user can, trough a dropdownbox, select the text of parameter1 but Here's where i'm stuck: when I get the button to take the parameter1 from dropdown box on the form, I'm not sure how to pass the parameter to query1, rather than Query3 which seems to be happening when I do:

DoCmd.OpenReport "reportA", acViewReport, , "[Parameter1] = '" & <textfromdropdown> & "'"

Unfortunately, the result from parameter1 being applied to query3, is not the same as the one I would obtained if the parameter1 were to be aplied for query 1, despite the fact that the field, let's call it field1, is found on query1, query2, and query3. The result on the reportA is of course not the one expected once the report finally opens.

I'm possibly doing the whole thing wrong with the query on top of query thing, but it works, slow, but it works, is there a way to get the parameter where it's needed through the code in my form?, or is there a better approach to get this to work, possibly merge my queries into one somehow? or do DoCmd.OpenQuery ?? in the right order before openReport is executed?? what would be the basic of the syntax for this "embedded " approach?

Thank you.
 

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