Quantcast
Channel: SCN : Discussion List - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 3636

How to pass parameters to a subreports

$
0
0

Hi all

 

I have a problem to pass parameters to a sub reports inside of a main crystal report.

 

The structure of the report is as follow

 

there is a main report that use a stored procedure

this main report have 3 independent sub reports that uses each one a different stored procedure

 

All the names of stored procedures are different, each one have 3 parameters and  the names of the parameters are @FechaI, @FechaF and

@Suc for all the stored procedures.

 

I'm using a dll for the handle of reports so i pass all the properties to the dll

 

for the parameters to pass to the sub reports  i am using this code

 

'5555/////////////////////////////////////////////

            ' IAR 25MZO2015

            ' Revisar si contiene subreportes el reporte principal

            ' review if contains sub reports the main report

            If ReporteCR.Subreports.Count > 0 Then

                ' revisa si tiene uso de subreportes con datasources

                ' review if the sub reports uses datasources

                If SubReportesDS.Count > 0 Then

 

 

                    For Each pair As KeyValuePair(Of String, System.Data.DataTable) In SubReportesDS

                        '''ReporteCR.DataDefinition.FormulaFields(pair.Key).Text = pair.Value

                        ReporteCR.Subreports.Item(pair.Key).SetDataSource(pair.Value)

                    Next

                End If

 

 

                ' revisa si tiene uso de subreportes con stored procedures y parametros.

                ' review if the sub reports uses stored procedures with parameters

                If SubReportesSPParam.Count > 0 Then

                    Dim sNombreSubrpt As String = ""

                    Dim iIndiceSubrpt As Int16 = -1

 

 

                    For Each oVal As SubReporteProps In SubReportesSPParam

 

 

                        If oVal._NombreSubRpt <> sNombreSubrpt Then

                            sNombreSubrpt = oVal._NombreSubRpt

                            iIndiceSubrpt = iIndiceSubrpt + 1

 

 

                            ' me logueo al sub reporte

                            ' log on into sub report

                            ReporteCR.Subreports.Item(iIndiceSubrpt).SetDatabaseLogon(sUsuario, sPwd)

                        End If

                        ' paso parametro, valor y nombre de sub reporte al metodo

                        ' i pass parameter, value and sub report name to the method

                        ReporteCR.SetParameterValue(oVal._NombreParam, oVal._Valor, oVal._NombreSubRpt)

                        '''ReporteCR.SetParameterValue(oVal._NombreParam, oVal._Valor, ReporteCR.Subreports(iIndiceSubrpt).Name.ToString)

                    Next

                End If

 

 

            End If

            '5555/////////////////////////////////////////////

 

after uses this code crystal report shows the parameters form to capture the values for the parameters.

 

I don't know what is happen.?

 

I need to do the log on for each sub report or not?

 

In total there are 12 parameters ( main report and 3 sub reports)

 

What's wrong,?

 

What can i do to complete this task?

 

thanks in advance for your help

 

Greetings


Viewing all articles
Browse latest Browse all 3636

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>