VB.Net - Crystal report direct to printer. Missing parameter values [modified]
-
I am getting the following error message "Missing parameter values." when I am trying to print directly to the printer. Below is my code. Works perfect if I want to view on screen but get the above error message when I try to print direct to my printer. If I did not have any parameter code etc, prints no bother to printer. Dim cr As New ReportDocument Dim param1Fields As New ParameterFields Dim param1Field As New ParameterField Dim param1Range As New ParameterDiscreteValue cr.Load("c:\MyReport.rpt") param1Field.ParameterFieldName = "PassedParameter" param1Range.Value = 123456 param1Field.CurrentValues.Add(param1Range) param1Fields.Add(param1Field) CrystalReportViewer1.ParameterFieldInfo = param1Fields 'View Report 'CrystalReportViewer1.ReportSource = cr 'Print straight to printer cr.PrintToPrinter(1, False, 0, 0) '(1, False, 0, 0)
modified on Friday, November 26, 2010 5:21 AM
-
I am getting the following error message "Missing parameter values." when I am trying to print directly to the printer. Below is my code. Works perfect if I want to view on screen but get the above error message when I try to print direct to my printer. If I did not have any parameter code etc, prints no bother to printer. Dim cr As New ReportDocument Dim param1Fields As New ParameterFields Dim param1Field As New ParameterField Dim param1Range As New ParameterDiscreteValue cr.Load("c:\MyReport.rpt") param1Field.ParameterFieldName = "PassedParameter" param1Range.Value = 123456 param1Field.CurrentValues.Add(param1Range) param1Fields.Add(param1Field) CrystalReportViewer1.ParameterFieldInfo = param1Fields 'View Report 'CrystalReportViewer1.ReportSource = cr 'Print straight to printer cr.PrintToPrinter(1, False, 0, 0) '(1, False, 0, 0)
modified on Friday, November 26, 2010 5:21 AM
IS_Assessor wrote:
CrystalReportViewer1.ParameterFieldInfo = param1Fields
I suspect your problem is here - you are assigning the parameter to the Viewer object, not the report document.
-
IS_Assessor wrote:
CrystalReportViewer1.ParameterFieldInfo = param1Fields
I suspect your problem is here - you are assigning the parameter to the Viewer object, not the report document.
Hi, Thanks for replying. I tried the following but still got the same message. cr.DataDefinition.ParameterFields("PassParameter").ApplyCurrentValues("123456") I agree I was assigning the parameter to the viewer object but I just cannot seem to get the syntax right to assign to cr. What is the correct syntax as I have tried all sorts code?
-
Hi, Thanks for replying. I tried the following but still got the same message. cr.DataDefinition.ParameterFields("PassParameter").ApplyCurrentValues("123456") I agree I was assigning the parameter to the viewer object but I just cannot seem to get the syntax right to assign to cr. What is the correct syntax as I have tried all sorts code?
try this:
crReportDocument.SetParameterValue(ParameterName, Value)
-
try this:
crReportDocument.SetParameterValue(ParameterName, Value)
Works a treat now. A big thank you and have a great weekend.
-
Works a treat now. A big thank you and have a great weekend.
Central_IT wrote:
Works a treat now. A big thank you and have a great weekend.
If you are that pleased then at least have the courtesy to give the guy a 5 vote!
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”