You can change the recordsource using code in the report's Open event, or
using the calling form. You can also make a copy of the report to a new name
and change the recordsource property.
You have it upside down. A Report or a Form depends on a query (or
Table) to provide data, not the other way.
If you have the query for your report in the query window with a name
I offer some words of caution. In cases such as you mention a named
query tends to get tweaked for the Report or Form you're currently
designing. Of course that will likely break it for any other Report
or Form that was using it. My query window is empty on most
applications. My queries are embedded in the Form or Report that uses
them.
How to fix it? Open the named query, change to SQL view and CTRL-A,
CTRL-C to copy it to the clipboard. Close the query
Open each Form or Report that uses that query in design view. Display
the properties and select the Data tab and then clear the RecordSource
entry. Click the ellipsis (...) and an empty QBE grid will be
displayed. Change the view to SQL, click in the window and then press
CTRL-V. That will write the SQL from the clipboard. Click the Close
button in the upper right of the window and answer the first prompt
"Yes". That will save your changes. Answer the next prompt "No" so
that you don't create a new named query. Continue that process for
each Form or Report that uses that same query.
Do the same thing for all other named queries whose dependent Forms
and Reports you know.
Rename every query in the Query Window as "Old_"QueryName. Run
everything in your application to see if everything still works. When
you're absolutely positive that everything works then make a backup of
your application and keep it safe. Only then should you delete the
OldQueryName queries. The objective all along has been to clear the
Query window as much as possible so that innocent fiddling with a
visible query won't cause problems.
Once the above is done then your best bet is to copy the Report you
have now and give it a new name such as rptReportFamilyNameTemplate.
Every time you need a new version of the report, just copy it again
and paste it as rptNewName. It will already have its query embedded.
Post back with questions.
HTH
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.