Printer dialog box before PRINT (1 Viewer)

Mr.K

Registered User.
Local time
Today, 14:54
Joined
Jan 18, 2006
Messages
104
Hi,

I used the code below to hide all the toolbars and then created my custom ReportToolbar so the user can print the report. All works OK; however, the PRINT button on my custom toolbar sends the report imidiately to the printer. How can I create a button that I could add to my custom toolbox which would open the dialog box that allows to choose the printer, number of pages to print, etc.. (same action as I can get by going to File->Print)?

PS> Also, is there any way to remove the drop down arrow from my custom toolbox? I disabled Customize Toolbox but the pulldown arrow still appears. I found making an MDE would take care of this, but was wondering if there was another solution.

Code used to hide toolbars:
Code:
For i = 1 To CommandBars.Count
    CommandBars(i).Enabled = False
    Next i
 

jkl0

jkl0
Local time
Today, 16:54
Joined
Jun 23, 2006
Messages
192
I picked this method up from some other site.

Do not preview but open print dialog !

Open your report in design view, add the following to the Report's On Activate event:

Private Sub Report_Activate()
On Error Resume Next
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, Reports!rptName
End Sub

Close and save the changes.

Now open the form where the cmdbutton is located to open the report. I'm assuming you are using DoCmd.OpenReport method to make your report print. Change that line to:

DoCmd.OpenReport "YourReportName", acViewPreview
(change "YourReportName" to the actual name of your report)

Don't worry about the acPreview argument causing the report to show on screen. The earlier code you placed in the report will keep this from happening.

When you click your button, the print dialog box will open so you can choose the printer options, the report will then print and close without becoming visible on screen.
 

Mr.K

Registered User.
Local time
Today, 14:54
Joined
Jan 18, 2006
Messages
104
Thanks jkl0; your post thought me some useful stuff but this is not quite what I need. I already have a menu bar (not a custom form with a button) and wish for the print button to display the "print window" before the report prints. I think I could use your solution successfully if I had a custom print button, but my button is the default one on the menu bar with a printer symbol on it. Why does it immediately print?? Can I somehow add a button to my custom menu bar that will first display the print window?
 

Users who are viewing this thread

Top Bottom