Link to home
Start Free TrialLog in
Avatar of MDauphinais1
MDauphinais1

asked on

Microsoft Access Display Print Dialog Window

I currently use this code to automatically print a certain report:

stDocName = "GroupbyAdmin"
    DoCmd.OpenReport stDocName, acNormal

How can I make the Print Dialog window (where you select your printer and settings, etc. instead of automatically printing?
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

the easiest way is

stDocName = "GroupbyAdmin"
    DoCmd.OpenReport stDocName, acViewPreview
will open the report in view mode

if you want to print
File >Print
SOLUTION
Avatar of Leigh Purvis
Leigh Purvis
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stevbe
stevbe

I create custom menus using drag-n-drop of the standard buttons etc. This print button is the one that I always make sure I am using the one from the standard File / Print menu instead of the Print on the toolbar. This way they always get the dialog.
Avatar of MDauphinais1

ASKER

Can I print the report without showing a preview?

ie: just use the  Docmd.Runcommand acCmdPrint command?  When I try this it is printing the form instead of the report.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you can try this

stDocName = "GroupbyAdmin"
    DoCmd.OpenReport stDocName, acViewPreview,,,acHidden
    Docmd.Runcommand acCmdPrint

but you have to handle the event when the user click the Cancel button in the print dialog
somethng like this

On Error Resume Next
Dim stDocName As String
stDocName = "GroupbyAdmin"
DoCmd.OpenReport stDocName, acViewPreview, , , acHidden
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, stDocName
I reckon that will still print whatever the active object is on screen.
So if you initiate this code from a form - the report will open hidden - not be visible (or hence able to receive focus) and the form will get printed.
:-(
LPurvis is right, it keeps printing the form. I tried to use a custom toolbar instead. You know how when you go to File --> Print it displays the print dialog but if you click on the printer icon on the toolbar it automatically prints? Well, I made a custom toolbar by selecting File-->Print as the button but when I click it, it is automatically printing and not displaying the dialog box.
Ahh, nevermind I got it. I just created a Macro for the SendKeys command and I made that the button. Now it displays the dialog.

Thanks.
But a toolbar will help you - *if* the report is the active object only.
That's your problem - and ultimate limitation, unless (as I say) you first manipulate the active printer - then do a standard OpenReport (acViewNormal so it prints) and then set the printer back again.

Personally - I'm usualy more comfortable giving users a look at what they're about to print out report wise - unless I'm just using a report as a paper output version of a form's data - in which case, what's to decide right? :-)
Yuk Macro.
You could make a function and call that from the toolbar.