2014-10-17 43 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