Click here to Skip to main content
15,036,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I need to print my reports directly to printer:

1) Without showing print dialogue box
2) Without showing the Reportviewer

I was suggested the following code:

VB
Dim printerSettings As New PrinterSettings()
        Dim printDialog As New PrintDialog()
        printDialog.PrinterSettings = printerSettings
        printDialog.AllowPrintToFile = False
        printDialog.AllowSomePages = True
        printDialog.UseEXDialog = True
        Dim result As DialogResult = printDialog.ShowDialog()

        If result = DialogResult.Cancel Then
            Return
        End If

        Me.rptSalesReport.PrintOptions.PrinterName = printerSettings.PrinterName
        Me.rptSalesReport.PrintToPrinter(printerSettings.Copies, False, 0, 0)


But I am receiving error on the last two lines, where I put the name of my reports,
rptSalesReport. It says:
VB
rptSalesReport is not defined.


While the rptSalesReport is there in my project and I can view it through report viewer.
Please advise.
Thanks
Posted
Comments
Chamadness 1-Apr-14 1:24am
   
very incomplete code you have here for anyone to help. Just make sure that you are creating an instance of the report and assigning it before running the code above.
Furqan Sehgal 1-Apr-14 3:01am
   
Can you kindly elaborate further how to create the instance and assign?
Is it like
Dim rptMyReport as new ...............

And how to assign it?
(give me complete code please)
bluesathish 22-Apr-14 2:06am
   
Did you use RDLC reports?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900