Skip to content

ImportSubReport - cDRReport

Methods - Properties - Events

Method Type

Function

Return Type

Integer

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.
sSubReportId The report ID of the sub-report to be re-imported
sFileName Name of the file that contains the sub-report definition

Description

Returns C_DR_SUBREPORT_IMPORT_SUCCESS on success or one of the error conditions. Consider the whole operation as sensitive. When it fails, it is better to close the report and re-open than try to continue.

The return is one of the SubReportImport Result Codes.

This method cannot be used before the report OCX object is initialized. The COM object creation is - when not done before - created as part of the OpenReport method.

DataFlex Framework usage

  • Web
  • Windows
  • FlexTron

Sample

Object oReport is a cDRReport
    Set psReportName to 'MyReport.dr'
End_Object

Object oRunReportButton is a Button
    Set Label to 'Run Report'

    Procedure OnClick
        Send RunReport of oReport
    End_Procedure
End_Object

Object oSubReportComboForm is a ComboForm
    Set Size to 12 100
    Set Location to 300 8
    Set Entry_State to False
    Set Combo_Sort_State to False
    Set peAnchors to anBottomLeft

    Procedure Combo_Fill_List
        Send Combo_Add_Item "Blue"
        Send Combo_Add_Item "Red"
    End_Procedure

    Procedure OnChange
        String sValue sReportId sSubReportId sFileName sFolder
        Integer eStatus

        Get psReportId of oReport to sReportId
        If (sReportId <> "") Begin
            Get SubReportId of oReport sReportId 0 to sSubReportId
            If (sSubReportId <> "") Begin
                Get ReportsFolder of oReport to sFolder
                Get Value to sValue
                If (sValue = "Blue") Begin
                    Move (sFolder - "BlueHeading.dr") to sFileName
                End                    
                Else Begin
                    Move (sFolder - "RedHeading.dr") to sFileName
                End
                Get ImportSubReport of oReport sReportId sSubReportId sFileName to eStatus
                If (eStatus = C_DR_SUBREPORT_IMPORT_SUCCESS) Begin
                    Send RefreshReport of oReport
                End
            End
        End
    End_Procedure
End_Object