Caution - I need very specific instructions as I am not at all proficient in VB.net or CR.
I want to enter a strNumber in a textbox on a windows form, and have it passed to a Crystal Report parameter for sorting (CR report is on the same form).
I'm using Visual Studio 2015/VB.net
I created a Windows form named frmSubSpecsReport
I created a Textbox on the form named txtJobNumber and a variable strJobNumber to hold the value that is typed into the textbox
I created a parameter in the report named JobNumber, which I will use to sort through all the jobs to find the correct one
I want to capture the number that a user types into the textbox and pass it to the JobNumber parameter in CR
I've used the Imports at the top of the form:
I've added this code for the button click event -
Dim ParameterFields As CrystalDecisions.Shared.ParameterFields
Dim ParameterField As CrystalDecisions.Shared.ParameterField
Dim ParameterDiscreteValue As CrystalDecisions.Shared.ParameterDiscreteValue
Dim strJobNumber As String = txtJobNumber.Text
'assign a report object to the viewer
Dim crSubSpecsReport As New CrystalReport1
I got an error using CrystalReport1 as not being referenced ?? So I added the following to get the error to go away, but really don't know what it does:
Private Class CrystalReport1
Then the code continues as follows:
CrystalReportViewer1.ReportSource = New crSubSpecsReport
'reference the parameterfields collection
ParameterFields = CrystalReportViewer1.ParameterFieldInfo
'reference the ParameterField object (name of the parameter i CR)
ParameterField = ParameterFields("JobNumber")
'create a parameterValue object
ParameterDiscreteValue = New ParameterDiscreteValue
'assign a default value
ParameterDiscreteValue.Value = "strJobNumber"
'add the ParameterValue object to the CurrentValues or DefaultValues collection
When I run the program, the CR parameter input form appears (not what I want) and when I enter a number, it does appear on the report, but if I use the textbox and click the button, then "strJobNumber" appears instead of the number entered.
Thanks very much for taking a look at this!