从外部代码向MS Access On Open事件传递值



我有许多MS Access报告。它们按州显示不同的统计数据。它们没有记录源属性集。"打开时"事件设置记录源属性。设置recordSource的例程的参数之一是"state"。默认情况下为"CA"。

现在,我想创建一个外部程序,它将遍历所有状态,并打印每个状态的每个报告。我的问题是,如何将状态值传递给打开事件函数?有办法做到这一点吗?

这是我的打开报告代码:

Private Sub Report_Open(Cancel As Integer)
     Call createReport(Me, New C_r01_r02_Sum_for_PPO_Only)
End Sub

这是createReport代码:

Sub createReport(rpt As Report, oRep As IReportClass, Optional rptState As String = "CA")
      'get the recordsource for the report
       rpt.recordSource = oRep.getSource(rptState)
End Sub

如果使用OpenReport打开报告,则可以使用函数的OpenArgs参数:

Sub OpenReport(ReportName, [View As AcView = acViewNormal], [FilterName], [WhereCondition], [WindowMode As AcWindowMode = acWindowNormal], [OpenArgs])

并且在报告检查的Open事件内使用OpenArgs属性:

if not Me.OpenArgs is Nothing then 
    ' do what ever you want
    ' 
end if

最新更新