Print Preview button on form

JeffreyDavid

Registered User.
Local time
Today, 01:44
Joined
Dec 23, 2003
Messages
63
:confused: I have a form with a print report button at the bottom. My code is:
On Error GoTo Err_PrintInvoice_Click

Dim strDocName As String

strDocName = "NcrPrintOut"
' Print NCR report, using NcrPrintOut Filter query to print
' invoice for current order.
DoCmd.OpenReport strDocName, acViewNormal, "NcrPrintOutQuery"

MsgBox "Your NCR #" & Me.NcrNo & " has been sent to the printer", vbOKOnly

DoCmd.Close

The only problem is that is goes right to the printer. Is there anyway I can get the report to open in print preview mode? I need the option of selecting a different printer depending on the status of the job the report is for.
 
I have the same problem. I also have a form with a print report button at the bottom. My code is:
On Error GoTo Err_Print_Form_Click

DoCmd.PrintOut
Exit_Print_Form_Click:
Exit Sub
Err_Print_Form_Click:
MsgBox Err.Description
Resume Exit_Print_Form_Click

End Sub

Is there a way I change this to get the report to open in print preview mode in a similar way?
 
This is a pretty old thread. You could create your own thread too :)

Here's how to open your report in preview mode:
Code:
DoCmd.OpenReport "Name of report here", acViewPreview

Welcome to AWF by the way
 
I prefer to give my users the choice...

Code:
    If MsgBox("Do you want print or preview the ''" & cboPrintReports & "'' report?" & vbCrLf & vbCrLf & "Click the Yes button to print the selected report." & vbCrLf & "Click the No button to preview the selected report.", vbQuestion + vbYesNo, "Print Or Preview Selected Report") = vbYes Then
        DoCmd.OpenReport sReportName, acViewNormal
        MsgBox "The selected report has been sent to your default printer.", vbInformation, "Printed " & cboPrintReports & " Report"
    Else
        DoCmd.OpenReport sReportName, acViewPreview
    End If
 
And if you want to take it up a notch, create option buttons "Print", "Preview" on a form so that when selected would determine the appropriate action to take.
 

Users who are viewing this thread

Back
Top Bottom