problem with report

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

Guest

I havea database that generates a report with a variable number of pages.

Sometimes the last page (which is configured to be in the report footer of
the whole report) has no data to be printed. But usually there is
information to be printed.

I use the inbuilt "Page x of y" to print the page number on the report
within the page footer.

My question is : If there is no information associated with this last
section of the report to be printed, how can I get the report to say page x
of (y-1) throughout the report, at the moment the headings (labels) for the
last section are permanent fixtures as is the page numbers.

I think what i want is the report footer only to appear (and if it does it
is to be always a separate page, ie the last page of the report) if there is
data to be printed, else the previous page (ie the last set of main report
data) is teh last page and the page xof y reflect this........help
 
you can use the ReportFooter section's OnFormat event to determine whether
or not there is data available for that section, and cancel the event if
there is not. as an example:

i created a simple report, and set the section's ForceNewPage property to
BeforeSection (just to ensure a separate page for the report footer). i
added an unbound textbox control (named Text12) to the section, and set the
ControlSource to
=1
i added a "page numbers" textbox control to the PageFooter section, same as
you're using in your report.

on opening the report, i see the records in the underlying table on the
first page, and a second page at the end that just shows "1" (the value of
the textbox control in the ReportFooter section). the pages are numbered
correctly as "Page 1 of 2" and "Page 2 of 2".
then i added the following code, to the ReportFooter section's OnFormat
event, as

Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)

Cancel = Not (Me!Text12 = 1)

End Sub

remember that the value of Text12 was set to 1, so when i opened the report,
i got the same result as before i added the code. next, i went back into
report design view, and changed the ControlSource of Text12 to
=2
then i opened the report again. this time (because the evaluation of "Text12
= 1" was False) the Format event was cancelled, and Access automatically
"fixed" the page numbers on the first page of the report. so in only the
first page of the report was displayed, and the page was corrected numbered
as "Page 1 of 1".

that's a long-winded explanation, but hopefully it illustrates the concept
of cancelling the ReportFooter section's Format event. exactly *how* and
*what* you check to determine when to do that, depends on where the data is
coming from and how it's displayed. for instance, is the data displayed in a
subreport? a textbox control? a label control? what generates (or doesn't
generate) the data?

hth
 
you're welcome. :)
if you find you need some help getting the concept to work, you can post
back with specific details of the origin and display method of the report
footer's data, and we'll work on figuring it out.
 
Back
Top