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

Open the print select screen before printing a report 1

Status
Not open for further replies.

rene1000

IS-IT--Management
Apr 9, 2002
89
NL
I have created a button which prints a report like this:

Dim stDocName As String
stDocName = "Incident report"
DoCmd.OpenReport stDocName, acNormal

I would however like to see the printer select screen (CTRL + P screen so to say) instead of a printout to the default printer. How can i do this ?

 
One approach would be to change your "acNormal" to "acViewPreview" which will take you to a report preview screen. Then you can select your printer from there.

However, there may be a way to bring up a list of your printers and select one from there. Not sure.

Tom
 
Hi!

I'm not saying it's impossible, but it's somewhat complicated.

When using the acnormal thingie, a lot of the reports events fires, one can have msgboxes popping up etc, but I can't make the print option dialog pop up. That's probably since it's ment to be a programatticaly equivalence of hitting the print-button -> print to the default printer.

The best way, would then be using the acpreview thingie in stead of acnormal.

To make the user "have" to consider which printer to use, add

sendkeys "^{p}"

to for instance the reports on open event.

If you still want to control your printer thru code, I'd recommend the book Access 200N Developer's Handbook by Getz, Litwin and Gilbert, Sybex, where classes and methods for this is available (classes you can use in your code)

HTH Roy-Vidar
 
ok, thanks for the help. i think i'll try the access book for the code.
 
Hi,

You can do this using the acCmdPrint RunCommand Constant. Look in help for all the available RunCommand Constants. You will find most commands that you would find on the built-in Menus avaialble there, for use in your code.

Place this in the Declarations section of a Module:
Public gShowPrintDialog As Boolean

In the On Activate event of any Report, paste this:
On Error Resume Next
If gShowPrintDialog = True Then
gShowPrintDialog = False
DoCmd.RunCommand acCmdPrint
End If

To show the Printer Dialog:
gShowPrintDialog = True
DoCmd.OpenReport "ReportName", acViewPreview

Using the variable "gShowPrintDialog" will give you the option to either open the report showing the Print Dialog or not to show it. Change "ReportName" to your report name(s).

Bill
 
billpower

Brilliant solution, as always.

But I can't make it work for opening with acnormal. Is this some version-thingie (using XP), or does this solution also work only on acpreview?

Roy-Vidar
 
Hi RoyVidar,

Thanks for the comments, much appreciated, but this one's been around for years, as I said most functions you find on the menu can be found among the RunCommand constants. I'm reiterating that because, if you think about it, using acNormal wouldn't give you the option to select File>> Print from the menu. So yes, this only works by using the acPreview constant so that the menu is accessible for the constant to work.

But, you have given me an idea to work on as a Tip. Will post link here if successful.

All the best and cheers.

Bill
 
I have a book called "Access Cookbook" by Getz, Litwin & Baron, O'Reilly Press. It shows the following procedure to retrieve a list of all installed output devices...

Add a list box to the form. Set its name to lstPrinters. Then put the follow code on the form's Load event...
Private Sub Form_Load()
Dim prt as Printer
lstPrinters.RowSourceType = "Value List"
For each prt in Application.Printers
listPrinters.AddItem prt.DeviceName & " on " & prt.Port
Next prt
End Sub

There are additional sections in the book which indicate how to let the user select from this list at run time. If this is helpful to you, let me know and I'll copy out the code and post it to you.

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top