Crystal Reports XI PrintToPrinter "Missing parameter values" - printing

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

Related

DevExpress Xtrareport Direct Print without preview

I create a Receipt Report by Xtrareport it work properly, what I need is:
vb.net code to print the report directly when pressing the Print Button without showing the preview report.
Use the ReportPrintTool class to create an instance of a report and immediately send it to a printer.
The Print a Report documentation offers sample code showing how to directly print a report using the ReportPrintTool.Print method. For instance:
Dim report As New XtraReport1()
Dim printTool As New ReportPrintTool(report))
' Invoke the Print dialog.
printTool.PrintDialog()
' Send the report to the default printer.
printTool.Print()

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

FastReport trouble print

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

Delphi: MAPILOGON ErrorCode 1

I tried with many versions of MAPISend, but I everytime got error in one place.
The MAPILogon returns with errorcode 1.
dwRet := MapiLogon(Handle,
nil,
nil,
MAPI_DIALOG or MAPI_NEW_SESSION,
0, #MAPI_Session);
I tried with "MAPISend component", this code:
http://prog.hu/tudastar/60044-6/Delphi-Email+csatolt+file+thunderbird.html
and 2 of others.
Interesting, that Acrobat Reader CAN use the MAPI with Attach to email function, and the "Send" "In Mail" context menu also working.
I don't understand why it isn't working, in my machine (Win7) it is working fine.
Then machines where I failed have WinXP OS, and they used Thunderbird.
What I can do to successfully logon into MAPI?
THanks:
dd
I think I found the problem.
The problem, that Delphi needs a Registry value named MAPI under
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Messaging Subsystem"
If this not present, it send 1 error code to you what is the base of the confusion.
This value must be string. The sysadmin wrote DWORD, and this caused the problem.
Thanks for your help:
dd
I am using RapWare components, http://www.rapware.nl/
Hth's.
Stanko.
I'm not sure about any Delphi-specific issues, but you don't need to call MAPILogon before calling MAPISendMail. If you do, I wouldn't check the return value. That's why Acrobat Reader was working and your SMAPI client was not.

Print FastReport directly

I'm using FastReport in Delphi Win32.
When a FastReport is called, it is previewed before you can print it.
The user sometimes needs to print a series of reports. It's a PITA to preview then print each one separately.
How can I queue the reports and send them directly to the default printer?
Just call PrepareReport followed by Print. You don't have to show the preview.
frxReport1.PrepareReport;
frxReport1.Print;
It's written in developper help file (Programmer Manual) Chapter "Building a composite report (batch printing)"
frxReport1.LoadFromFile('1.fr3');
frxReport1.PrepareReport;
frxReport1.LoadFromFile('2.fr3');
frxReport1.PrepareReport(False);
frxReport1.Print;

Resources