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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Possible to Pass Arguments to a Sub-Report?

Status
Not open for further replies.

GGleason

Technical User
Mar 22, 2001
321
US
I have a report that needs to pass arguments to a sub-report? Is that possible?

tia,
GGleason
 
Use the Parent property.

SubFormControl = 2 * Parent![MainFormControl]
will show on the subform the value from the main form multiplied by 2

HTH

[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Daniel,

Do you know if it possible to pass arguments to the sub-report while the report is printing?

Thanks,
GGleason
 
As far as I know, printing or previewing a report are practically the same for Access, so I guess both following lines will pass the value from the main report to the subreport:

DoCmd.OpenReport "ReportName" 'this will print the report
DoCmd.OpenReport "ReportName", acPreview 'this will display it on the screen

If you mean changing the recordsource, this is only possible in the Open event of the report, so you can't do it 'while' printing or previewing.

However, you can filter the existing records after you have already opened the report, but this has effect only in Preview mode, because if you print it directly, the report is closed immediately after having been rendered to the printer.

Have I missed the point???

I hope you understand more than I do from what I wrote here...[lol]



[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Daniel,

You are correct in mentioning the record source of the sub-report. I was attempting to change it on the fly (great in theory – failed in practice) based upon the year as the printing progressed. The SQL code was valid but it was a “no-no” to change the record source while the printing was in progress. Another thought was to send arguments to the sub-report and let it do what I wanted it to do based upon the arguments.

My workaround was to make two labels and place the contents of the query into the labels, which is a poor solution since the labels (unlike text boxes) can’t grow. It worked but it wasn’t the elegant solution that I had hoped to find.

Thanks,
GGleason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top