I'm writing an application in VB 2005 with CR2008 where i need to print CR report. I get an error when i try to do it.
Here is my code:
' cr1.FileName = MyPath + "\Reports\ReportRetourSource.rpt"
cr1.Load(MyPath + "\Reports\ReportRetourSource.rpt", [Shared].OpenReportMethod.OpenReportByDefault)
cr1.Database.Tables(0).Location = MyPath & "\Database Files\MyDb.mdb"
'cr1.ExportToDisk([Shared].ExportFormatType.PortableDocFormat, MyPath + "\Reports\MyReport.pdf")
cr1.PrintToPrinter(1, False, 0, 0)
The error appears when i'm on the last line (printtoprinter) and the message is "Trying to divide by zero".
I changed te "True" by "False" and i get the same error.
Then i decided to use the CRViewer to avoid that error and here is the code I add to my application:
''''''''cr1.PrintToPrinter(1, False, 0, 0)
CRV1.ReportSource = cr1
now it works but the problem is that each time I call the PrintReport method, the printdialog appears even if I already have chosen the printer via the PrintDialog1.ShowDialog object in the beginning of the class.
Does somebody have a solution for me????