Closing print preview after printing

R

Rich Stone

My database has two buttons for printing and previewing a report on the
screen that displays the main records. I have already used vb to bring up the
report in full screen and zoomed to 100% when the 'Preview' button is
clicked, and the standard windows dialog box comes up when the 'Print' button
is clicked. However, once the print dialog is cleared, either after printing
or after the 'Cancel' button is pressed, a preview window remains on the
screen.

How do I close this preview automatically? Is it actually possible to
prevent the preview window from being displayed in the first place?
 
F

fredg

My database has two buttons for printing and previewing a report on the
screen that displays the main records. I have already used vb to bring up the
report in full screen and zoomed to 100% when the 'Preview' button is
clicked, and the standard windows dialog box comes up when the 'Print' button
is clicked. However, once the print dialog is cleared, either after printing
or after the 'Cancel' button is pressed, a preview window remains on the
screen.

How do I close this preview automatically? Is it actually possible to
prevent the preview window from being displayed in the first place?

How are you opening the report in the first place?
DoCmd.OpenReport "ReportName", acViewNormal
will print the report without preview.
 
F

fredg

My database has two buttons for printing and previewing a report on the
screen that displays the main records. I have already used vb to bring up the
report in full screen and zoomed to 100% when the 'Preview' button is
clicked, and the standard windows dialog box comes up when the 'Print' button
is clicked. However, once the print dialog is cleared, either after printing
or after the 'Cancel' button is pressed, a preview window remains on the
screen.

How do I close this preview automatically? Is it actually possible to
prevent the preview window from being displayed in the first place?

How are you opening the report in the first place?
DoCmd.OpenReport "ReportName", acViewNormal
will print the report without preview.
 
R

Rich Stone

Thanks for the reply. I had acPreview instead of acViewNormal but when I
changed it as you suggested the print dialog stopped coming up! So I've
changed it back to bring back the print dialog but still need the preview to
close afterwards.

Any other ideas?
 
R

Rich Stone

Thanks for the reply. I had acPreview instead of acViewNormal but when I
changed it as you suggested the print dialog stopped coming up! So I've
changed it back to bring back the print dialog but still need the preview to
close afterwards.

Any other ideas?
 
F

fredg

Thanks for the reply. I had acPreview instead of acViewNormal but when I
changed it as you suggested the print dialog stopped coming up! So I've
changed it back to bring back the print dialog but still need the preview to
close afterwards.

Any other ideas?

Don't open the report at all. Try:

On Error GoTo Err_Handler
DoCmd.SelectObject acReport, "ReportName", True
DoCmd.RunCommand acCmdPrint

Exit_Sub:
Exit Sub
Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error # " & Err.Number & " " & Err.Description
End If
Resume Exit_Sub

This will bring up the same dialog you get using File + PrintOut
without opening the report in Preview.

Why do you need the Print dialog?
 
F

fredg

Thanks for the reply. I had acPreview instead of acViewNormal but when I
changed it as you suggested the print dialog stopped coming up! So I've
changed it back to bring back the print dialog but still need the preview to
close afterwards.

Any other ideas?

Don't open the report at all. Try:

On Error GoTo Err_Handler
DoCmd.SelectObject acReport, "ReportName", True
DoCmd.RunCommand acCmdPrint

Exit_Sub:
Exit Sub
Err_Handler:
If Err = 2501 Then
Else
MsgBox "Error # " & Err.Number & " " & Err.Description
End If
Resume Exit_Sub

This will bring up the same dialog you get using File + PrintOut
without opening the report in Preview.

Why do you need the Print dialog?
 
R

Rich Stone

Thanks again for your assistance. I have noted this method for future
developments but for now I have come up with a workaround. Rather than having
a button for previewing and a button for printing, I have now got just one
button that shows a preview and a pop-up box asking whether the user would
like to print it.

To answer your question of why I needed the print dialog, our business
shares various printers and on occasion the default printer may be in use by
somebody else. Also, the number of copies varies from time to time. On this
note, do you know if it is possible to alter the initial settings of the
print dialog? For example, if most of the time two print copies are required,
is it possible to make the default number of copies on the print dialog two?
 
R

Rich Stone

Thanks again for your assistance. I have noted this method for future
developments but for now I have come up with a workaround. Rather than having
a button for previewing and a button for printing, I have now got just one
button that shows a preview and a pop-up box asking whether the user would
like to print it.

To answer your question of why I needed the print dialog, our business
shares various printers and on occasion the default printer may be in use by
somebody else. Also, the number of copies varies from time to time. On this
note, do you know if it is possible to alter the initial settings of the
print dialog? For example, if most of the time two print copies are required,
is it possible to make the default number of copies on the print dialog two?
 

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