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

page numbers

Status
Not open for further replies.

ITbeast

IS-IT--Management
Jul 25, 2006
67
US
I have a strange problem to overcome, hopefully someone out there has an idea of how i can approach this.

I need to print a report of data collected on a particular day. But the hang up is that i need to pring cumulative page numbers. for example, on day one the data is collected, put into the db then printed as pages 1 of 30, 2 of 30, and so on. on day two, the reports need to be printed as 31 of 60, 32 of 60 and so on.

we don't want any extra user interaction. i considered prompting the user what page number the report needs to start at, but that idea was over ruled.

any ideas?
 
i should add that on my report i already prompt the user for the date that they wish to view data for and the area for which they want data for
 
You could create a new table that just has one field, "LastPageNumber" to hold the last page number printed. Then, in your report design, add some code behind the ReportHeader_Format event to retrieve that value, increment it by 1 and set [Page] equal to your new number. Also, in your ReportFooter_Format event, add code to set your "LastPageNumber" field to the value of [Page].
 
I added a table called "PageNumber" with one field called "LastPageNumber" (of type Number/Integer), and added one record, setting it to 0 (be sure to add the record).

Then, in the report design view, I added the Report Header and Footer (off the View menu). In the ReportHeader_Format event, I have the following code...

Code:
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
    
    Dim intLastPageNumber As Integer
    
    intLastPageNumber = Nz(DLookup("[LastPageNumber]", "PageNumber"), 0)
    intLastPageNumber = intLastPageNumber + 1
    
    [Page] = intLastPageNumber

End Sub

And in the ReportFooter_Format event, I have this block of code...

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

    Dim intLastPageNumber As Integer

    intLastPageNumber = [Page]
    
    DoCmd.SetWarnings False
    DoCmd.RunSQL "UPDATE PageNumber SET LastPageNumber = " & intLastPageNumber
    DoCmd.SetWarnings True
    
End Sub

I have tested this solution, and it works...I hope it fits your needs. Good Luck!
 
with a few tweaks that were specific to my report, that code worked great. thanks for the help rjoubert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top