Reputation: 25
I am using VB6 and Crystal Report 8.5 and I want to print my report directly with the default printer without preview and clicking the print button. I have this code and but when ever I try to print it shows me the preview and i have to click Print button for print process Here is my code
With MAIN.CR
.Reset: MAIN.InitCrys
.ReportFileName = App.Path & "\Reports\rptCashInvoice.rpt"
.Connect = "POS"
strTitle = "Cash Invoice"
strSelFormula = "{Cash_Sales.InvoiceNo} ='" & InvoiceNo & "'"
.SelectionFormula = strSelFormula
.WindowTitle = strTitle
.ParameterFields(0) = "prmCompany;" & CurrBiz.BUSINESS_NAME & ";True"
.ParameterFields(1) = "prmAddress;" & CurrBiz.BUSINESS_ADDRESS & ";True"
.ParameterFields(2) = "prmContactInfo;" & CurrBiz.BUSINESS_CONTACT_INFO & ";True"
.PrintReport
.DiscardSavedData = True
End With
Upvotes: 1
Views: 8243
Reputation: 384
Try something like:
Dim crxApp As CRAXDRT.Application
Dim crxRpt As CRAXDRT.Report
Set crxApp = New CRAXDRT.Application
Set crxRpt = crxApp.OpenReport("C:\MyReport.rpt")
crxRpt.PrintOut False, NoCopies
If you need to print the report on other printer than default, try to use SelectPrinter.
Upvotes: 1