Report with subreport get error access violation

Click image for larger version. 

Name:	DR50.png 
Views:	136 
Size:	39.6 KB 
ID:	9582
Code:
    // Close the report    { Visibility = Private }
    Procedure ComReportClose String llsId
        Handle hDispatchDriver
        Get phDispatchDriver to hDispatchDriver
        Send PrepareParams to hDispatchDriver 1
        Send DefineParam to hDispatchDriver OLE_VT_BSTR llsId
        Send InvokeComMethod to hDispatchDriver 2 OLE_VT_VOID
    End_Procedure
when i remove subreport from the report no error

Code:
Use cWebView.pkgUse cWebPanel.pkg
Use cWebButton.pkg
Use cWebGroup.pkg
Use cWebForm.pkg
Use cWebEdit.pkg
Use cWebRadio.pkg
Use cWebCombo.pkg
Use cWebCheckBox.pkg
Use cWebLabel.pkg
Use cWebIFrame.pkg
Use cWebMenuGroup.pkg
Use cWebMenuItem.pkg
Use cWebDRReport.pkg
Use cWebDRReportViewer.pkg
Use ExportReport.wo


Object oAanmeldingen2ReportView Is A cWebView
    Set psCaption to "Aanmeldingen2"
    Set pbShowCaption to False
    Set peWebViewStyle to wvsDrillDown


    Object oReport is a cWebDRReport
        Set psReportName to "Aanmeldingen2.dr"


        Procedure OnInitializeReport
            String sReportId


            Get psReportId to sReportId


            Send ChangeODBCDataSource sReportId
            Send SetFilters
            Send SetSortFields
        End_Procedure


        Procedure SetSortFields
            // You can add sort fields using the AddRecordSortField method and remove sort fields with RemoveAllRecordSortFields.
        End_Procedure


        Procedure SetFilters
            String sReportId
            // You can use the method AddFilter to add a filter or set the filter via psFilterFunction


            Get psReportId to sReportId
        End_Procedure


        // Activate the code inside this method if you want to change the database connection
        Procedure ChangeODBCDataSource String sReportId
            String sConnectionString sDSN sSubReportId
            Integer iSubReports iSubReport


            Get psDatabaseConnection sReportId to sConnectionString
            Get psDatabaseName sReportId to sDSN
            // ToDo: Change the contents of sDSN and/or sConnectionString
            Set psDatabaseConnection sReportId to sConnectionString
            Set psDatabaseName sReportId to sDSN


            Get SubReportCount sReportId to iSubReports
            Decrement iSubReports
            For iSubReport from 0 to iSubReports
                Get SubReportId sReportId iSubReport to sSubReportId
                Send ChangeODBCDataSource sSubReportId
            Loop
        End_Procedure




    End_Object


    Object oWebMainPanel is a cWebPanel
        Set piColumnCount to 12


        Procedure RunReport
            Send GenerateReport of oReport
        End_Procedure


        Object oViewer is a cWebIFrame
            Set pbFillHeight to True
            Set pbShowBorder to True
            Set phoReportViewer of oReport to Self
        End_Object
    End_Object


    Procedure OnShow
        Send RunReport of oWebMainPanel
    End_Procedure


    Set pbServerOnShow to True
End_Object