printer dialog box

barbarossaii

Master of Disaster
Local time
Today, 14:02
Joined
Dec 28, 2002
Messages
70
Hi,

got a form on which I created a print button via the wizard. The button works, but it prints the report without the printer dialog box appearing.

What must be changed in the code created by the wizard to make the printer dialog box appear ?

I've searched this site already but found no detail solution (explaining exactly what to delete and what to add in the code)....


Thanks in advance for your help,
Barbarossa II
 
DoCmd.RunCommand acCmdPrint

That command will call the default Print dialog box. Ensure that you trap for error # 2501 [if the user clicks the Cancel button].

FYI: Stay away from the wizards if you really want to control your objects.

HTH
 
Last edited:
Sorry,


I didn't get your answer. I changed the code for the button to:


Private Sub Befehl4_Click()
On Error GoTo Err_Befehl4_Click

Dim stDocName As String

stDocName = "rpt_MONATSBERICHT"

DoCmd.RunCommand acCmdPrint 'rem CHANGED

'rem CHANGED "DoCmd.RunCommand acCmdPrint" instead of the wizard-created "DoCmd.OpenReport stDocName, acNormal"

Exit_Befehl4_Click:
Exit Sub

Err_Befehl4_Click:
MsgBox Err.Description
Resume Exit_Befehl4_Click

End Sub



Now only the form is printed; I'd like to print only the report; it could be opened before & closed after printing, but it would be even better if it stays closed; the important thing for me is to get the printer dialog box additional to the "DoCmd.OpenReport stDocName, acNormal" printing method.

Please explain in detail what to change (plz copy my thread & change & post; otherwise I won't get it.....;-(

TIA,
Barbarossa II (<---------newbie to Access....)
 
What options are in the Print dialog box that you need to use instead of DoCmd.OpenReport?

What are you trying to do that a simple DoCmd.OpenReport will not do?

DoCmd.OpenReport "rpt_MONATSBERICHT"
 
ghudson,

with the printer dialog box I'd like to

- give the user the possibility to change the printer

- let the user choose the pages which will be printed

- allow the user to print to a printer (existing hardware) or to a pdf-writer (allready installed & working with printer dialog boxes from Word, xls,...)



Barbarossa II
 
I suggest that you open the report in the print preview mode and then call the print dialog box.

DoCmd.OpenReport "YourReportName", acViewPreview
DoCmd.RunCommand acCmdPrint

HTH
 
Ghudson...


The way I have it setup is this: the user can preview the report via the "preview button".. Then if they want to print it they close that down and hit the "Print button" and it prints the report with out previewing it.. How can I have it so when they hit the print button the print dialog opens up and they can chose what printer they send the report to?

I have the following code:

Code:
Private Sub cmdPrintEmpNum_Click()
On Error GoTo Err_cmdPrintEmpNum_Click
Dim stDocName As String

stDocName = "rptEmpNum"
DoCmd.OpenReport "rptEmpNum", acNormal, , "[EmployeeNumber]=" & Me.cboEmployeeNumber
Exit_cmdPrintEmpNum_Click:
Me.cboEmployeeNumber = Null
Exit Sub

Err_cmdPrintEmpNum_Click:
MsgBox Err.Description
Resume Exit_cmdPrintEmpNum_Click
End Sub

I have tried the

Code:
 DoCmd.RunCommand acCmdPrint

In various places but I either get the report printed twice, the form and report printed, etc.. never just the report.. Where and what do I need to change in order to make this happen?

Thanks
R~
 
From an archive I have:

Displaying Print dialogue box without displaying form:

Set the code on the command button to docmd.openreport “ReportName”, acViewPreview

Add the following to the "On Activate" event of the report.

Private Sub Report_Activate()
On Error GoTo Err_Report_Activate

If Me.Report.HasData Then
DoCmd.RunCommand acCmdPrint
DoCmd.Close acReport, Me.Name

Else
MsgBox "There is no data for this report. Canceling report...", vbInformation, " Your App"
DoCmd.Close acReport, Me.Name

End If

Err_Report_Activate:
Resume Next
DoCmd.Close acReport, Me.Name

End sub

HTH

Dave
 
Hello...

How can I put this code into what I am doing with the code above?? This is what is so frustrating to me..


Thanks
R~
 
stick it in the onclick event of your button
 
Oldsoftboss said:
From an archive I have:

Displaying Print dialogue box without displaying form:

Set the code on the command button.....

Bloddy Hell :confused: :confused:
 

Users who are viewing this thread

Back
Top Bottom