将表单打开到特定选项卡

时间:2013-08-23 11:40:01

标签: vba ms-access access-vba tabcontrol

按下按钮时,我想在特定标签页面打开表单。

点击事件我有:

DoCmd.OpenForm "MAIN_USER_FORM", acNormal, , "App_Ref = " & Me.App_Ref, , , "PRB"

在表格的公开活动中:

If Me.OpenArgs = "PRB" Then
   Me.PRB_Validation.SetFocus

End If

PRB_Validation是我想要打开的MAIN_USER_FORM中的标签名称。

我搜索了表单,我无法让它工作任何帮助都会很棒。 提前致谢。

2 个答案:

答案 0 :(得分:3)

您只需要检查表单的OpenArgs事件中的OnLoad,并将TabCtontrol的值设置为您要显示的页面的索引,如下所示:

Private Sub Form_Load()
    If OpenArgs = "PRB" Then
        TabCtl0.Value = PagePRB.PageIndex
    End If
End Sub

我让an example accdb显示完整设置。

答案 1 :(得分:1)

如果有人正在查找您在另一个表单上有按钮的代码,并且想要从中打开主表单并将用户带到特定的选项卡。

Private Sub YourButton_Click()
On Error GoTo Err_YourButton_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "YourFormName"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Forms![YourFormName]!YourPage.SetFocus

Exit_YourButton_Click:
    Exit Sub

Err_YourButton_Click:
    MsgBox Err.Description
    Resume Exit_YourButton_Click

End Sub
相关问题