Hi all, i'm going to post this here and in the Crystal Reports section to see if I can get more help on both sides.
Anyway, here is what I have:
I have a small vb.net app that runs reports made in crystal reports 10.
There is one report that has multiple selections for a parameter in the report. So I made a bunch of checkboxes and once the user checks them and runs the report, this code runs:
Now this code will add up all the different selections, and then group them in a single STRING variable.
Then I push over some info into the report like so:
strRPTparameter is what my STRING parameter in Crystal Reports is named. I have the manual selection code setup in the report as {IM_ITEM_MASTER_MC.Item_Category} like {?@cat}. Nothing out of the ordinary here....
Then in the report I use this code:
NOW........... this basic code (minus the check box grouping) has worked fine for me in the past, and I do not think it is the problem.
I think the probem is the string variable comes out like this = PARTS, COVE, MISC .... I think it needs to actually be = "PARTS", "COVE", "MISC" within in the string in VB.NET... I do not know how to do this because of the "" problems.
Any other ideas???
Anyway, here is what I have:
I have a small vb.net app that runs reports made in crystal reports 10.
There is one report that has multiple selections for a parameter in the report. So I made a bunch of checkboxes and once the user checks them and runs the report, this code runs:
Code:
Public Sub checkboxes()
strCat = ""
If CheckBox1.Checked = True Then
strCat = "ABRA "
End If
If CheckBox2.Checked = True Then
strCat += "BRUS "
End If
If CheckBox3.Checked = True Then
strCat += "BUCK "
End If
If CheckBox4.Checked = True Then
strCat += "COVE "
End If
If CheckBox5.Checked = True Then
strCat += "HOSE "
End If
If CheckBox6.Checked = True Then
strCat += "PART "
End If
If CheckBox7.Checked = True Then
strCat += "ROLL "
End If
If CheckBox8.Checked = True Then
strCat += "SASP "
End If
If CheckBox9.Checked = True Then
strCat += "TAPE "
End If
If CheckBox10.Checked = True Then
strCat += "TOOL "
End If
If txtCinput.Text <> "" Then
strCat += txtCinput.Text
strCat += " "
End If
'go through and insert COMMA where spaces
strCat = strCat.Replace(" ", ", ")
strCat = strCat.Substring(0, strCat.Length - 2
Now this code will add up all the different selections, and then group them in a single STRING variable.
Then I push over some info into the report like so:
Code:
txtRptStr.Text = "P:\ForeFront v12\Custom Reports\OIHpCallV.rpt"
strRPTparameter = "@cat"
checkboxes()
strRPTinput = strCat
Dim frm As New Report2
frm.F1 = Me
frm.Show()
strRPTparameter is what my STRING parameter in Crystal Reports is named. I have the manual selection code setup in the report as {IM_ITEM_MASTER_MC.Item_Category} like {?@cat}. Nothing out of the ordinary here....
Then in the report I use this code:
Code:
Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load
cr = New CrystalDecisions.CrystalReports.Engine.ReportDocument
cr.Load(F1.txtRptStr.Text)
Dim param1Fields As New CrystalDecisions.Shared.ParameterFields
Dim param2Field As New CrystalDecisions.Shared.ParameterField
Dim param2Range As New CrystalDecisions.Shared.ParameterDiscreteValue
param2Field.ParameterFieldName = F1.strRPTparameter
param2Range.Value = F1.strRPTinput
param2Field.CurrentValues.Add(param2Range)
param1Fields.Add(param2Field)
CrystalReportViewer1.ParameterFieldInfo = param1Fields 'to pass parameter inf.to CRV
CrystalReportViewer1.ReportSource = cr ' Assign Report Source to CRV
CrystalReportViewer1.Refresh()
'test
MessageBox.Show(F1.strRPTinput)
MessageBox.Show(F1.strRPTparameter)
End Sub
NOW........... this basic code (minus the check box grouping) has worked fine for me in the past, and I do not think it is the problem.
I think the probem is the string variable comes out like this = PARTS, COVE, MISC .... I think it needs to actually be = "PARTS", "COVE", "MISC" within in the string in VB.NET... I do not know how to do this because of the "" problems.
Any other ideas???