2014-10-17 52 views
0

我有许多MS Access报告。他们显示国家差异统计。他们没有recordource属性集。 “打开”事件设置记录来源属性。设置recordSource的例程的一个参数是“状态”。默认情况下它是“CA”。将值传递给MS Access从外部代码打开事件?

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

这是我在开放报告代码:

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 

回答

1

如果使用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