親レポートを読み込んだ後、親レポートを実行する前に、サブレポートを変数に読み込み、サブレポート コントロールのオブジェクト プロパティをその変数に設定する必要があります。例えば:
' 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
mySubReport.rpx
ここで、サブレポート ファイル名 (上記の例) またはサブレポート コントロール名 (上記の例) をハードコーディングできない場合MySubreportControl
は、親レポートのすべてのコントロールをループして各サブレポート コントロールを見つけるルーチンを作成できます。次に、サブレポート コントロールの ReportName または Tag プロパティに、サブレポートのファイルの名前を格納してください。次に、コード内のサブレポート コントロールを使用して、サブレポート ファイルを動的にロード/リンクできます。特定のヘルプが必要な場合は、コメントとして質問に返信してください。
また、ActiveReports ドキュメントの COM バージョンは、オンラインで入手できます(アーカイブ)。
Scott Willeke
GrapeCity