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?
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?
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?
Related
I am having trouble printing reports with FastReport in Delphi 2010.
When printing to the printer the first time, it prints correctly, but the second time that I try to print the report does not print correctly.
Viewing on my computer is working correctly, the problem is when I will print on the printer that the problem happens.
frxReport1.LoadFromFile(FileRep);
if isPrint then begin
frxReport1.PrepareReport();
frxReport1.Print;
end else
frxReport1.ShowReport;
For exemple:
The wrong form (the first time):
The correct form (the second time):
Try to use latest FR 5.5.11. If problem still exists - create small demo project with error and send it to FR's support https://support.fast-report.com/tickets
The application was written in TD 6.2 version. When trying to print using builtin function SalReportPrint()-InavlidPrintCommand error has been received. I have already tried Menu Report->Format->Report option( qrp file) and selected the check box use defult printer option but still getting same error.
had this case several times, using an older version of TD (4.1).
There my problem was that either the printer which it reported that it should be printing on was not installed or it wasn't set as a default printer.
Try to set your printer of choice to be default printer, using SalPrtSetDefault() before you do the printing action.
I'm working on an issue with a Crystal report (Crystal XI running in a VB app) where a sporadic "Missing parameter values" error is received when trying to print the report directly. Here's a summary of the issue:
User runs the report via the report menu (everything works fine)
User clicks 'Print Preview' (everything works fine)
User clicks 'Print' (supposed to send the document directly to the printer, but sometimes get missing parameter error)
Here is what I had for code to start:
crystalReportViewer.MdiParent = parent
crystalReportViewer.Show()
Dim report As ReportDocument = CType(crystalReportViewer.ReportSource, ReportDocument)
report.PrintToPrinter(1, False, 0, 0)
crystalReportViewer.Close()
crystalReportViewer.Dispose()
Based on what I've been googling, I came up with this code:
crystalReportViewer.MdiParent = parent
crystalReportViewer.Show()
Dim report As ReportDocument = CType(crystalReportViewer.ReportSource, ReportDocument)
'here are my attempts to get it to work
Dim pf As ParameterFields = report.ParameterFields
report.PrintOptions.PrinterName = "Microsoft XPS Document Writer"
report.PrintToPrinter(1, False, 0, 0)
crystalReportViewer.Close()
crystalReportViewer.Dispose()
I'm about out of ideas on how to solve this issue. Has anyone else run across this?
Start Code: You problably have some empty parameter in your report.
After Search Code: You have this line:
Dim pf As ParameterFields = report.ParameterFields
You have a parameter, and you are not setting any value.
For both, use:
//[C#]
report.setParameterValue(parameterName, parameterValue);
It's very simple. Make sure that all of your parameters inside the report are filled and thrown data before using "printtoprinter". I have solved it with that.
As far as I can tell, this looks like an issue in Crystal. I couldn't find a fix, so I'm just using a workaround until a fix is available (report is generated and then printed manually).
First you need to add PrintDialog from toolBox
then add the following code button_click_event
ReportName.PrintOptions.PrinterName = PrintDialog1.PrinterSettings.PrinterName
ReportName.PrintOptions.PaperOrientation = CrystalDecisions.[Shared].PaperOrientation.Landscape
ReportName.PrintOptions.PrinterName = "Microsoft XPS Document Writer"
ReportName.PrintToPrinter(PrintDialog1.PrinterSettings.Copies, True, 1, 99)
This would send printing directly to "Microsoft XPS Document Writer". vote if you found this helpful
I have a BEAST of a program written in VB6. It uses ActiveReports to generate letters.
The reports are processed in a loop; with verbage-building loops and (a whole lotta) nested 'if' and 'case' statements. Fugly!
The reports are sent to the printer like such:
Function PrintIt(ltrobj as Object)
Set ltrobj = MyARdocument '(.Dsr file)
ltrobj.txtfield1 = strVerbage 'This string was populated somewhere else
ltrobj.Printer.DisplayProgressDialog = False
ltrobj.PrintReport False
End Function
Now here's the weird part: The pages physically come out of the printer rotated 90 degrees each iteration of the loop. What's even weirder -- this only happens for my VB6 application -- other Word documents, reports, batch jobs, whatever come out normal.
So the first page comes out like normal, the header first (pointing North). The second page comes out sideways (header pointing West). The third comes out of the printer like the first, the fourth comes out like the second, and on and on...
The printer: A Ricoh Aficio MP5000
I cannot find a setting on the printer, or a property in ActiveReports that controls this.
Any ideas, help, or a general direction would be greatly appreciated!
Thanks,
Jason
There is no "rotation" setting in ActiveReports. The closest things that might impact this would be the page size and orientation, but at worst I would expect them to flip back and forth not actually rotate the page. I would try to do a few things:
Trace the printer & page settings related to orientation and page size as report prints.
Try printing to another printer to see if it happens on all printers or just this one.
Preview the reports on screen and see if they're rotated in the preview or not (or export them to PDF with report.Export(...) ad see if they're rotated there).
To trace page settings you should do it in a couple places. One on the printer, and another on each page (or Canvas) in the report. There is also the ActiveReport.PrintWidth (the width of the report, not the pages) that may also be relevant. So just before printing each report try tracing out the following values:
report.PrintWidth
' the default settings for the report
report.PageSettings.TopMargin
report.PageSettings.RightMargin
report.PageSettings.BottomMargin
report.PageSettings.LeftMargin
' actual printer's current settings:
report.Printer.PaperSize
report.Printer.PaperHeight
report.Printer.PaperWidth
report.Printer.Orientation
' settings for a specific page:
for each page in report.Pages:
report.Pages(...).Width
report.Pages(...).Height
report.Pages(...).Orientation
BTW: ActiveReports COM Help is here.
If the preview/PDF test seems okay then I'd focus on the printer itself. Same for the print to another printer obviously. Otherwise, focus on ActiveReports settings.
Hope this helps
Scott Willeke
GrapeCity
Having a strange problem where a print occasionally is not being printed
The scenario is that we print barcode labels with a barcode printer (Zebra LP2844).
Printer is plugged into the TerminalPC and then shared.
Printer->TerminalPC -> Terminal Server.
Session on TerminalServer is using Printer as \TerminalPC\Printer
When logging print Events we see the following:
Print OK:
1) Print OK (Event 10, User myUser)
2) Print deleted (Event 13, User NT-AUTHORITY\SYSTEM)
Print not OK => only Event 2) appears in the event log
Anybody having a clue about what is happening here?
More information:
This problems occurs about 2 out of 10 times. Only difference is an increasing ID being printed as part af the barcode.
The barcode is the only object being printed. It saves to file (*.emf) every time - and looks fine on file.
The application is developed using Delphi 2010 and works fine in all other ways.
Print jobs are removed from the print spooler by the port monitor. The port monitor "EndDocPort" function calls "SetJob" with JOB_CONTROL_SENT_TO_PRINTER to indicate the the job has finished, and this removes it from the spooler.
If the printer uses a custom port monitor, the problem could be in the printer driver or custom port monitor. If it uses a standard port such as LPT or USB, it's more likely a problem with the application not calling "EndDoc" consistently, or not checking return codes from EndDoc.