“Print Warning†when Printing a continuous type form

E

EdGrenzig

RE: “Print Warning†when Printing a continuous type form

Access 2000

I would like below listed program code to warn a user how many pages are
going to print before the program issues the print command after the “print
form command button†is clicked on. The form is a continuous type form and
therefore has multiple pages depending how many records are filtered out.
When clicking on the “Print Command Button†on the form, this could print
hundreds of pages if a user is not careful. Normally they would filter the
records to a few pages before printing, but accidents do happen!

I would like a warning box to pop up on the screen that says
“ Warning: 23 pages are going to print! Do you want to continue?â€
Then you click on Yes or No. The code would have to calculate the number of
pages. 23 is just an example. (another option would be to click on PRINT,
PRINT PREVIEW, or NO EXIT) after the warning is displayed.

The present visual basic code that executes is as follows:

Private Sub Command120_Click()
On Error GoTo Err_Command120_Click

Dim stDocName As String
Dim MyForm As Form

stDocName = "Form2"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acForm, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.Name, False

Exit_Command120_Click:
Exit Sub

Err_Command120_Click:
MsgBox Err.Description
Resume Exit_Command120_Click

End Sub

This code has no print warning. I am not a programmer so I am hoping someone
can give me the code to add the warning or direct me where to get it.

Thanks
 
B

Brendan Reynolds

'small number just for testing -
'calculate your average number of
'records per page
Const lngcRecordsPerPage = 3

Dim lngPages As Long
Dim intResponse As Long

'divide number of records by records per page, round up
lngPages = MyForm.RecordsetClone.RecordCount \ lngcRecordsPerPage _
+ Abs((MyForm.RecordsetClone.RecordCount Mod lngcRecordsPerPage) <>
0)
intResponse = MsgBox("This will print " & CStr(lngPages) & _
" pages. Continue?", vbYesNo)
If intResponse = vbYes Then
'print
Else
'don't
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top