Number of Pages on a Dynamic Report

Robert Dunstan

Mr Data
Local time
Today, 20:20
Joined
Jun 22, 2000
Messages
291
Hi all,

I have a form which allows the user to choose the criteria and select what type of report he/she wants to print. One of these reports that can be printed is a job transaction list which basically shows the purchase orders booked to a job and the transactions on each order. This means the report can be any number of pages long.

At the present the report is opened in preview, however what I also want to do is to give the user the option to print it straight out without previewing it first. With this option is there a way of informing the user that the report contains 'n' number of pages, do they wish to continue printing?

If they choose 'Yes' then start printing, if they choose 'No' then display the report in print preview.

Hopefully that makes sense, any help much appreciated

Rob
 
Since you know roughly how many records will fit on a page, you can count the underlying recordset
 
Hi Rich,

Yes that would work. Presumaby the best method to use would be the DCount function?

Basically the user selects from a form what job they want to print on then the JobNumber value is passed to the underlying query of the report.

So on that basis in the reports On_Open event I presume the code is something like this:

PHP:
Dim intCounter As Integer ' Record Counter
Const intRecord = 30 'Avg no of record per page
Dim intPages as Integer

intCounter = DCount("ID","tblOrderDetails","[JobNumber]=Forms!frmSelectJob!txtJobNumber")
intPages = intCounter / intRecord

strMessage = "There are " & intPages & " pages in this report. Continue?"
style = vbYesNo+vbExclamation+vbDefaultButton1

Response = MsgBox(strMessage,style)

If Response = vbNo Then
   DoCmd.SetWarnings False
   Cancel = True
End If
 

Users who are viewing this thread

Back
Top Bottom