SubReportIDByName - cDRReport¶
Methods - Properties - Events
Method Type¶
Function
Return Type¶
Arguments¶
| Argument | Description |
|---|---|
sReportID |
ID of the report. Can be ID of the main report or the ID of a sub-report. This argument can be passed as an empty string. The empty string can be written as C_USEMAINDRREPORTID. |
sSubReportName |
The name of a sub-report for which you want to retrieve the report ID. |
Description¶
Returns the ID of a sub-report with a given name.
The function operates recursively, meaning that it can be called from the main report. When nested sub-reports have the same name, the function call should start with the sub-report level that contains the report with the passed name. The ID of the first sub-report found with the passed name will be returned. An empty string will be returned if no sub-report can be found with the passed name.
Instead of using this method, you can enumerate the sub-reports using SubReportCount and SubReportId.
The name of a sub-report is the object name in the report that includes the sub-report. To change the name, modify the object name in DataFlex Reports Studio via the field properties dialog.
This method cannot be used before the report OCX object is initialized. The COM object creation is performed as part of the OpenReport method if it has not been done beforehand.
DataFlex Framework usage¶
- Web
- Windows
- FlexTron
Sample¶
Object oReport is a cDRReport
Set psReportName to 'MyReport.dr'
Procedure SetParameters
String sReportId sSubReportId
Get psReportId to sReportId
Get SubReportIDByName sReportId "Orders Subreport" to sSubReportId
If (sSubReportId <> "") Begin
Set psParameterValue sSubReportId 1 to 'Y'
End
End_Procedure
End_Object
Object oOpenReportButton is a Button
Set Label to 'Open Report'
Procedure OnClick
String sReportId
Get OpenReport of oReport to sReportId
If (sReportId <> '') Begin
Send SetParameters of oReport
Send OutputReport of oReport
Send CloseReport of oReport sReportId
End
End_Procedure
End_Object
Notes¶
- The above code assumes the sub-report contains two parameters and sets parameter 1. It is safer to use ParameterIdByName instead of assuming the parameter id is 1.