我在MS Access 2011中創建了一個表單,其中有一個名爲TabCtl18的頂部的選項卡控件,其中3個選項卡是page1,page2,page3。 在page1選項卡下還有另外3個其他選項卡page11,page22,page33,在三個選項卡下分別有3個報告檢查MS Access窗體中的哪個選項卡被點擊/激活
現在我希望當用戶點擊pdf圖標時,檢查哪個選項卡已經點擊並打印該報告。
我的代碼:
Private Sub cmdPrintReportPDF_Click()
If TabCtl18.TabIndex = 0 Then
If tab_graph.TabIndex = 0 Then
DoCmd.OpenReport "Graph_report", acViewNormal
DoCmd.OutputTo acOutputReport, "Graph_report"
DoCmd.Close acReport, "Graph_report"
End If
Else
If tab_graph.TabIndex = 2 Then
DoCmd.OpenReport "Graph_Report_FieldShifts", acViewNormal
DoCmd.OutputTo acOutputReport, "Graph_Report_FieldShifts"
DoCmd.Close acReport, "Graph_Report_FieldShifts"
End If
End If
End Sub
給選項卡控件添加有意義的名稱並使用它們會更好,因爲如果添加選項卡,名稱不會更改,但選項卡索引可以更改。 – 2011-05-28 22:16:31