views:

812

answers:

1

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

A: 

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

enriquein
It prompts me to answer an Input with Pm-?CustID as the input name.
Bruno43
You are correct, it is something to do with passing the parameters down to the subreports but I don't see what I did different with this report than any of the others that I created....
Bruno43