Pergunta

I have a lagacy project (vb6) which has several reports (.rpx) next to the project execution file (.exe). When user executes the .exe file, it downloads the .rpx file to a specified local folder of user machine and with 'LoadLayout' statement, it gets all the .rpx report file format into a variable of type: DDActiveReports2.ActiveReport and finally shows it.

Now, my question is: I need to embed a subreport into the main report said about it above. The subreport file is in vb project NOT next to exe file. How can I make a relation between main report and the subreport and feed the subreport with a recordset based on some data the main report uses them?

Thank you

Foi útil?

Solução

After you load the parent report, you will need to load the subreport into a variable, and set the subreport control's object property to that variable before running the parent report. For example:

' Load parent report:
Dim rptParent As New ActiveReport
rptParent.LoadLayout App.Path & "\myParentReport.rpx"

' Load the subreport:
Dim rptSubreport As New ActiveReport
rptSubreport.LoadLayout App.Path & "\mySubReport.rpx"

' * Initialize the subreport control by passing the actual report to run as a subreport:
Set rptParentReport.Sections("Detail").Controls("MySubreportControl").Object = rptSubreport

' Preview the parent report in the viewer:
ARViewer21.ReportSource = rptParent

Now, if you cannot hardcode the subreport file name (mySubReport.rpx in my example above) or subreport control name (MySubreportControl in my example above) then you can write a routine to loop through all controls in the parent report and find each subreport control. Then, make sure you store the name of the subreport's file in the ReportName or Tag property of the subreport control. Then you can dynamically load/link subreport files with subreport controls in your code. Please reply with your questions as a comment if you need some specific help with that.

Also, the COM version of ActiveReports Documentation is available online here (archive) in case that might be useful.

Scott Willeke
GrapeCity
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top