Link to home
Start Free TrialLog in
Avatar of jsctechy
jsctechyFlag for United States of America

asked on

Array list for a report

hi there,
I have a sub that it needs to take a list of parameters and pass it to the a report.
my problems occurs when i have to pass the parameters and get the values out from the array is there a way you experts can help me?

here is my code:

Public Shared Sub GenerateReport(ByVal strRptName As String, ByVal ParamArray param() As String)

        Dim crReportDocument As ReportDocument
        Dim pFieldDefs As ParameterFieldDefinitions
        Dim mypFieldDef As ParameterFieldDefinition
        Dim pVal As ParameterValues = New ParameterValues
        Dim pDiscreteVal As ParameterDiscreteValue = New ParameterDiscreteValue

        Try
            crReportDocument = New ReportDocument
            crReportDocument.Load("C:\Reports\" & strRptName)
            crReportDocument.SetDatabaseLogon("park", "park")
            pFieldDefs = crReportDocument.DataDefinition.ParameterFields

            Dim objectlist As String
            For Each objectlist In param

                pDiscreteVal.Value = objectlist.Substring(0)
                pVal.Add(pDiscreteVal)
                mypFieldDef = pFieldDefs(objectlist)
                mypFieldDef.ApplyCurrentValues(pVal)

            Next
            ' crReportDocument.ExportToDisk(ExportFormatType.RichText, strExportPath)
            'crReportDocument.PrintToPrinter(1, True, 1, 1)

        Catch ex As Exception
            Windows.Forms.MessageBox.Show(ex.Message)
        End Try
    End Sub

the only thing i know is that this part is not working and it is setup wrong:
For Each objectlist In param

                pDiscreteVal.Value = objectlist.Substring(0)
                pVal.Add(pDiscreteVal)
                mypFieldDef = pFieldDefs(objectlist)
                mypFieldDef.ApplyCurrentValues(pVal)

            Next
how can i change in order to pass my values to the report?
Avatar of Mike McCracken
Mike McCracken

What does this return  objectlist.Substring(0)

mlmcc


Avatar of jsctechy

ASKER

when execute objectlist.Substring(0) gives me the first value to be past

the line before: For Each objectlist In param hold every value of my paremeters list but from here onwards it getting stuck!!!  how can i pass the value of each pair to pDiscreteVal and mypFieldDef?

i hope that helps
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Glad i could help

mlmcc