Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One Report Form for more than 1 query

Status
Not open for further replies.

Jackie

MIS
Feb 9, 2000
148
US
Can one report form be used to display data from different queries?  My customer wants two identical reports.  Both reports show the same data.  One is sorted by name, the other is sorted by Division.  I would like to use the same report format for both reports.  
 
you could simply copy the report, paste it in with a different name, and change the source to the second query (if this is what you're looking to accomplish).<br>you'll have two of the same report, just with different orders.<br>and you can set it so that when you run one report, the other is automatically run as well. <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
 
You can add an option group, which lets users decide to sort the report by name or division, in the form that calls the report. Then set the OrderBy property in the runtime in the Report_Load event procedure.<br><br>Private sub Report_Load()<br><br>if forms!frmReportDialog.optSortedBy =1 then<br>&nbsp;&nbsp;&nbsp;&nbsp;me.orderby=&quot;[Name]&quot;<br>else<br>&nbsp;&nbsp;&nbsp;&nbsp;me.orderby=&quot;[Division]&quot;<br>end if<br><br>me.orderbyon=true<br><br>end sub<br><br>I assume that the form is called frmReportDialog and the option group is called optSortedBy.<br><br><br><br>
 
Here's how that works.<br><br>Form or report uses a recordset called 'TheRecordSource'. As in <br><br><i>form1.recordsource = &quot;TheRecordSource&quot;<br>form1.refresh</i><br><br><br>We play with the recordsource; dependent on user input, results of a query, time of day, colors in the rainbow, and then change the querydef for &quot;TheRecordSource&quot; then refresh the form. The name of the recordsource stays the same, however the query itself changes. After we change the query we refresh the form and the changes are displayed in our form our report. Simple.<br><br><br><br> <p>Amiel<br><a href=mailto:amielzz@netscape.net>amielzz@netscape.net</a><br><a href= > </a><br>
 
Amiel, how would I change only the search criteria for an existing query programmatically? I don't want to recreate the whole querydef, only change the search criteria - and I want it to change depending on which tab page it's on (that part I've figured out).&nbsp;&nbsp;Thanks.<br><br>P.S. I've tried to get the form to point to another query as recordsource and you're right, I can't get that to work as it keeps looping back to the beginning of On Form Current.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top