检查在MS Access表单中单击了哪个选项卡/处于活动状态

问题描述

| 我已经在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
    

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...