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

Coding section format events in sub-reports

Status
Not open for further replies.

sko

Technical User
Dec 9, 2000
283
US
I'm setting a report footer's visible property based on records in the detail section of the report. The code works when the report is run separately but not when it's run from the main report.

The report is a form letter used for price quotes.

Main Report Page Header Section
Contractor, Address, "We are pleased to quote..."

Main Report Detail Section
Sub-report which contains products and prices

Main Report Footer Section
The rest of the letter

The sub-report footer section contains a footnote about "Product X". When "Product X" is included in the price quote for the contractor, the footer is visible, otherwise it's not.

Here's how the sub-report works:
I have an unbound control in the sub-report footer.
On the sub-report ReportHeader_Print event I set unbound control = false. As the sub-report detail lines are printed, if "Product X" is included, the unbound control is changed to true. On the sub-report ReportFooter_Format event I set section(acFooter).visible = unbound control.

When I run the sub-report as part of the main report I get an invalid use of null on that line. I've deleted the ReportFooter_Format procedure and checked the value of the unbound control at the end of the ReportHeader and ReportDetail print events and the value is true or false. Could it be that the sub-report ReportFooter_Format event is triggered before the events in the sub-report?
 
Sub-reports behave differently when part of the main report. The order of events can sometimes prevent you from manipulating certain controls or properties. A work around I've found useful is to open the subreport before opening the mainreport(you may have to insure the recordset will match what would be linked to the mainreport), let the formatting and print events (via printpreview, don't actually print the subreport) do their thing. Save then close the subreport. Then trigger the mainreport. Usually, the opening, saving and closing of the subreport happen so fast as to not be noticable by the user.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top