Avatar of fhenreaux
fhenreauxFlag for Belgium asked on

Error Printtoprinter CR 2008

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????


Crystal Reports

Avatar of undefined
Last Comment

8/22/2022 - Mon
Mike McCracken

I think the printreport will take a FALSE/TRUE as an arguement.  This controls the viewing of the dialog.


i'm not sure, i think it doesn't accept any argument.

About the error with the PrinttoPrinter, do you have any idea?


Yes, I tried today and it doesn't accept true or false.

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Mike McCracken

I'll try to find my code for VB6.  I built my own printer control and got it to print without the dialog.

I don't have it on this machine.


Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question