H
hughess7
Hi all
I have some code I found on the forum for creating Page numbering to run
sequentially over two different reports ie report 1 starts at page 1 and
report 2 starts at the end of report 1 + 1. This works when I code reports to
print, report 2 starts at Page 6 as desired. But when I code to preview the
reports only (how they normally work) the page numbering is not correct in
that report 2 starts at page 2 (instead of 6).
Do I need something in between the docmd.openreport preview commands calling
the two reports, maybe some sort of time delay to wait for report 1 to finish
processing? Or is it because I haven't moved through the pages when its
previewed so it hasn't triggered/looped through its formatting section fully?
Thanks for any help...
Code on each report is:
Dim intLastPage As Integer
Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)
DoCmd.SetWarnings False
DoCmd.RunSQL "Update tblPage Set tblPage.intPagenumber=" & [Page] & ";"
DoCmd.SetWarnings True
End Sub
Private Sub Report_Open(Cancel As Integer)
' only on report 1 reset PageNo to start at 0
DoCmd.SetWarnings False
DoCmd.RunSQL "Update tblPage Set tblPage.intPagenumber=0;"
DoCmd.SetWarnings True
intLastPage = DLookup("[intPageNumber]", "[tblPage]")
End Sub
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
[Page] = [Page] + intLastPage
End Sub
I have some code I found on the forum for creating Page numbering to run
sequentially over two different reports ie report 1 starts at page 1 and
report 2 starts at the end of report 1 + 1. This works when I code reports to
print, report 2 starts at Page 6 as desired. But when I code to preview the
reports only (how they normally work) the page numbering is not correct in
that report 2 starts at page 2 (instead of 6).
Do I need something in between the docmd.openreport preview commands calling
the two reports, maybe some sort of time delay to wait for report 1 to finish
processing? Or is it because I haven't moved through the pages when its
previewed so it hasn't triggered/looped through its formatting section fully?
Thanks for any help...
Code on each report is:
Dim intLastPage As Integer
Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)
DoCmd.SetWarnings False
DoCmd.RunSQL "Update tblPage Set tblPage.intPagenumber=" & [Page] & ";"
DoCmd.SetWarnings True
End Sub
Private Sub Report_Open(Cancel As Integer)
' only on report 1 reset PageNo to start at 0
DoCmd.SetWarnings False
DoCmd.RunSQL "Update tblPage Set tblPage.intPagenumber=0;"
DoCmd.SetWarnings True
intLastPage = DLookup("[intPageNumber]", "[tblPage]")
End Sub
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
[Page] = [Page] + intLastPage
End Sub