Guides & Tutorials (beta)

Printing a Report

by Mike Palmatier Visual Basic 6 Created on 05/03/2008  |  Updated on 07/31/2024 0/5 ( 0 votes )

To print a report only a single line of code is needed. The PrintReport method is used to print the currently visible report. A zero 0 is passed in as the only parameter to use the systems default printer.

'Printing using the default printer dialog
wndReportControl.PrintReport 0

You can also use the CommonDialog control to print. With a CommonDialog control, the CommonDialog.hDC property returns a device context for the printer selected in the Print dialog box when the cdlReturnDC flag is set. See the sample below for more on how to do this.

'Printing using the CommonDialog Control
    On Error Resume Next

    With dlgCommonDialog
        .DialogTitle = "Print"
        .CancelError = True
        .Flags = cdlPDReturnDC + cdlPDNoPageNums
        .ShowPrinter
        If Err <> MSComDlg.cdlCancel Then
            wndReportControl.PrintReport .hDC
        End If
    End With

User Comments

No comments yet, sign in to comment.

New Year Sale 2025

Secure Transactions

Online transactions are secure and protected.


Ssl seal 1
This site is protected by Trustwave's Trusted Commerce program
CompliAssure Secured

Money Back Guarantee

If you are not 100% happy with your purchase within 30 days, you can return it for any reason. Your satisfaction is our priority!


Satisfication Guarantee

Contact sales@codejock.com for more details.