问题描述
|
我已经在MS Access 2011中创建了一个窗体,该窗体的顶部有一个名为TabCtl18的选项卡控件,其中3个选项卡分别为page1,page2,page3。
在page1标签下还有另外3个标签page11,page22,page33,在三个标签下分别有3个报告
现在,我希望当用户单击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\",\"Graph_Report_FieldShifts\"
DoCmd.Close acReport,\"Graph_Report_FieldShifts\"
End If
End If
End Sub
解决方法
根据@David突出显示的问题,以下是检查所选“ѭ1”名称的方法。
if tabControl1.Pages(tabControl1.Value).Caption = \"TabPageName\" then
\'Do Something
end if
此外,您可以在Tab
控制Click
事件中使用此代码来检查哪个页面处于活动状态。
,选项卡控件的“值”(默认)属性是具有焦点的页面的索引。它从零开始。
If TabCtl18.Value = 0 Then
\'this must be the first page