简体   繁体   中英

Printing a Crystal Report directly to printer

I am creating a label printing function in a program that needs to create labels for the given information. I have created a label in Crystal Reports 9 but I'm having trouble printing it.

I don't want to save the label, I just want it to print directly after the system has created it.

Dim ap9 As craxdrt.Application
Dim rpt9 As craxdrt.Report
Dim dbt As craxdrt.DatabaseTable

Set ap9 = New craxdrt.Application
On Error GoTo errError2

Set iniFile = New CIniFile
On Error GoTo errError3

Set rpt9 = ap9.OpenReport(iniFile.pathReports & REPORT_LABEL_IN)
On Error GoTo errError4

For Each dbt In rpt9.Database.Tables
    dbt.Location = iniFile.pathDbCosmet
    If dbt.ConnectionProperties.count <= 5 Then
        dbt.ConnectionProperties.Add "Database Password", iniFile.passwordCosmet
    End If
Next

rpt9.RecordSelectionFormula = sFormula
rpt9.PrintOut False, CInt(txtPacksReceived.Text)

The following code allows me to select a printer

在此处输入图片说明

and after clicking 'Print' at that point I am shown another dialog

在此处输入图片说明

However, the code executes fine, there are no errors, but the print queue doesn't show any documents and the report doesn't print.

Is there some reason why I'm not able to print my labels?

Most likely your report doesn't contain any data - some logical error in selection/suppression formulas or similar.

If you print to any other printer, does something print out? Tracing SQL (assuming your report is bound to SQL server), can you see issued query? Does it look correct?

I've had problems with Zebra printers in the past that all turned out to be driver related. Have you uninstalled the printer driver and reinstalled it? Otherwise try unplugging and removing the device, plugging it into a different port and trying again?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM