troubleshooting Question

Error Printtoprinter CR 2008

Avatar of fhenreaux
fhenreauxFlag for Belgium asked on
Crystal Reports
5 Comments1 Solution392 ViewsLast Modified:
Hi
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.Refresh()
   '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
CRV1.PrintReport()
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????

Regards


 
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros