Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple String Parameter from .NET to CR10 trouble 1

Status
Not open for further replies.

Hueby

MIS
Oct 20, 2004
321
US
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:

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???
 
To embed double quotes in a string in VB, do this:

If CheckBox1.Checked = True Then
strCat = """ABRA"" "
End If

and so forth. This puts double quotes around the ABRA and leaves a space at the end.




I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top