I am having trouble trying to pass three parameters to a crystal report. I have a datatable that contains each parameter field name and the respective values as entered by the user. I am getting no error messages, however, when I set the report source for the reports viewer, I am still getting prompted to enter the parameters.
I am even displaying a message box for each parameter before the report is displayed that verifies each parameter actually has a value. I have been trying to figure this out for three days and it is getting very frustrating. At least if I was getting an error message I could have something to work with. Do any of you see something wrong with my code Again, the datatable being passed to the subroutine contains two columns - parameter field name and the value.
Public Sub Show_Report(ByVal paramTable As DataTable) Dim i As Integer Dim myFields As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions Dim thisField As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition Dim myValue As CrystalDecisions.Shared.ParameterDiscreteValue Dim my_Param_Name As String Dim my_Param_Kind As CrystalDecisions.Shared.ParameterValueKind Dim crCurrentValues As CrystalDecisions.Shared.ParameterValues
crDoc =
New CrystalDecisions.CrystalReports.Engine.ReportDocumentcrDoc.Load(rptFile)
myFields = crDoc.DataDefinition.ParameterFields
'Loop through each parameter field in report' For Each thisField In myFieldsmyValue =
New CrystalDecisions.Shared.ParameterDiscreteValuemy_Param_Name = thisField.ParameterFieldName
my_Param_Kind = thisField.ParameterValueKind
'Find matching parameter name in dataset to get value' For i = 0 To paramTable.Rows.Count - 1 If paramTable.Rows(i).Item(0) = my_Param_Name.ToString ThenmyValue.Value = paramTable.Rows(i).Item(1)
crCurrentValues = thisField.CurrentValues
crCurrentValues.Add(myValue)
thisField.ApplyCurrentValues(crCurrentValues)
Exit For End If Next Next For Each thisField In myFields 'Show whether or not each parameter has a value'MsgBox(thisField.ParameterFieldName & " = " & thisField.HasCurrentValue())
NextCrystalReportViewer1.ReportSource = rptFile
End Sub
Problem passing parameters to Crystal Report...
kiewie
jlgrau
Hi,
Can you try using
CrystalReportViewer1.ReportSource = crDoc
instead to see if it works
Hope this helps, regards.