Consecutive page numbers on multiple reports
Mark
I do it a little different way. The following only works if you print to a
printer, If you print Preview, the results are unpredictiable because you
can't guarantee report 1 to to the last page before report 2 previews.
Basically I put the last page number of report 1 in a control on the
calling form.
On Report 1 (Note you could have it on all reports)
On the ReportFooter - On Format '(Note the first line just confirms the
form is open)
If dbIsOpen(acForm, "frm_RateTableRpt") = True Then
Forms!frm_RateTableRpt.txtPage = Me.Page
End If
On Report 2 (Note you could have it on all reports)
On Report 2 header - On format
If dbIsOpen(acForm, "frm_RateTableRpt") = True Then
Me.Page = Forms!frm_RateTableRpt.txtPage + 1
End If
This function is not necessary - if you want it it's yours
Public Function dbIsOpen(ObjType As Integer, ObjName As String) As Boolean
'Accepts: dbIsOpen(acForm, "frm_zs_Proper")
' dbIsOpen(acReport, "rpt_zs_Object Modification")
' dbIsOpen(acTable, "Employees") - acQuery AcMacro -
'Returns: True - if open (design or regular mode or hidden)
' False - if not open or name wrong
'New: 7/8/97 LJG Updated 11/10/98
On Error GoTo dbIsOpen_Err
If Programming_Mode Then On Error GoTo 0
'----
If SysCmd(acSysCmdGetObjectState, ObjType, ObjName) = 0 Then
dbIsOpen = False
Else
dbIsOpen = True
End If
'----
'
dbIsOpen_Done:
Application.Echo True
Exit Function
dbIsOpen_Err:
msgbox Err.Description
Resume dbIsOpen_Done
End Function '----------------------------------
Good Luck
Larry Gordon
Business & Computers
Quote:
> Hello! My database has several reports that the users want to print
either
> individually, or as part of a larger group of several reports. Problem is
> page numbers.
> When the user selects a group of reports to print, I want the page
numbers
> to run consecutively throughout the reports: e.g., if first report is 3
> pages long, second report should start with page 4 as the number of the
> first page. Same for all successive reports in the group.
> I'm trying to programatically set the starting page number for each
> successive report by adding 1 to the last page of the previous report
using
> this method:
> Per MS help and references, I have two subs in a module like so (message
> boxes are for testing):
> public intLPN as integer
> Sub SetLPN(ReportName As Report)
> intLPN = ReportName.Page
> MsgBox "last page is " & intLPN
> End Sub
> Sub readLPN(ReportName As Report)
> ReportName.Page = intLPN + 1
> MsgBox "first page of this report is " & ReportName.Page
> End Sub
> In each report, I have an event procedure on the ReportFooter_Format
event:
> SetLPN Me
> In the second and successive reports I have an ep on Report_Open event:
> ReadLPN Me
> When I run both reports in succession, for the first it's picking up the
> correct last page. For the second report, the message box displays the
> correct .Page value, but when the report is displayed, its page number
> starts at 1.
> I'm not sure if it's the code that's screwed up or my selection of
events.
> Any help will be appreciated!