Posted 7 March 2019, 5:15 pm EST
I have a report with two subreports. I want to run or not run each subreport based on a condition. Is this possible?
Forums Home / ActiveReports / ActiveReports v7+
Posted by: george.viveiros on 7 March 2019, 5:15 pm EST
Posted 7 March 2019, 5:15 pm EST
I have a report with two subreports. I want to run or not run each subreport based on a condition. Is this possible?
Posted 8 March 2019, 6:37 am EST
Hi,
Yes, it is possible to choose the SubReports from the Parent Report based on some condition. For instance, you can use the Visible property of SubReport control in the Detail’s Format Event to control the visibility of the subreports based on a counter variable incremented each time Detail.OnFormat event is fired. The following steps should be performed for this case:
A sample has been attached here for your reference where the reports are bound to NWIND.mdb shipped with the product.
Similarly, you can use your own conditions to view subreports conditionally.
Regards,
Esha
[zip filename="ChooseSubReports.zip"]https://gccontent.blob.core.windows.net/forum-uploads/file-289b5df8-fe33-4f1d-9f05-72426ab8b849.zip[/zip]
Posted 12 March 2019, 11:47 am EST
Thanks.
Posted 12 March 2019, 12:34 pm EST
Your example is confusing. Your subreport names and almost identical on both side of the equal signs. Can you change the names on one side to be different?
Posted 13 March 2019, 12:22 am EST
Hello,
I have attached the modified application with changed field names. Here, “subReportFld_1” and “subReportFld_2” are the names of SubReport controls added to the report. Similarly, “firstSubRpt” and “secondSubRpt” are the instances of the code-based subreport files.
Thanks.
ChooseSubReports_mod.zip