I am trying to pass parameters from Visual Studio using VB.net to a Crystal report.
I am using the following code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If IsDate(MaskedTextBox1.Text) Then
Dim report As New invoice4
report.SetParameterValue(0, gCustId)
report.SetParameterValue("CustID", gCustId)
report.SetParameterValue("inputDate", MaskedTextBox1.Text)
Try
report.DataSourceConnections.Item(0).SetConnection("", "" & My.Settings.storeCS, False)
Catch ex As Exception
MsgBox(ex.Message)
End Try
gReport = ""
With removenotice
.CrystalReportViewer1.ReportSource = report
.ShowDialog()
End With
Else
MsgBox("Please Enter a Valid Date")
End If
End Sub
but every time I run it gives me a prompt for:
Pm-?CustID
Which when entered then gives me a “Field Not None”
So I try to replace the first ParameterValue:
report.SetParameterValue(0, gCustId)
with
report.SetParameterValue(“Pm-?CustID”, gCustId)
It then gives me the error:
Operation illegal on linked parameter.
If I click okay it still promts me for the CustID and inputDate and ultimately gives me the correct report.
Any suggestions?
Thanks
Are you sure you are linking it correctly to the sub-report? I’m getting the impression that it has something to do with passing the parameter down to a subreport.
Did you try running the report without this line: report.SetParameterValue(0, gCustId) ?