View Full Version : Number of Pages on a Dynamic Report


Robert Dunstan
07-04-2003, 08:36 AM
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

Rich
07-04-2003, 10:14 AM
Since you know roughly how many records will fit on a page, you can count the underlying recordset

Robert Dunstan
07-07-2003, 01:49 AM
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:

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

Rich
07-07-2003, 05:57 AM
If Response = vbNo Then
Else
DoCmd. do something