Report query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have constructed reports with sub reports that obtain thier data from a
query.
My question is is it possible to change the query that they are bound to
using vba?
Thanks
Ian
 
You cannot use the Open event of the main report to change the RecordSource
of the subreport, because Access opens the subreport first.

You cannot use the Open event of the subreport. The main report repeats the
subreport each time it needs to, and you cannot reassign the RecordSource
differently for each time it is called.

You can change the SQL of the query that the subreport is bound to before
you open the main report. For example, if the subreport is bound to Query1:
CurrentDb.QueryDefs("Query1").SQL = "SELECT ...
DoCmd.OpenReport "Report1", acViewPreview
 

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

Back
Top