简体   繁体   English

将表单打开到特定选项卡

[英]Open a form to a specific tab

When a button is pressed I want to open a form at a specific tab. 按下按钮时,我想在特定选项卡上打开表单。

on click event I have: 点击事件我有:

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

On the open event of the form I have: 在我有的形式的公开事件:

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

End If

PRB_Validation is the name of the tab in the MAIN_USER_FORM I wish to open. PRB_Validation是我要打开的MAIN_USER_FORM中的选项卡的名称。

I've searched forms, I just can't get it to work any help would be great. 我搜索了表单,我无法让它工作任何帮助都会很棒。 Thanks in advance. 提前致谢。

All you need is to check the OpenArgs in the form's OnLoad event, and set the TabCtontrol's value to the index of the page you want to show, like this: 您只需要在表单的OnLoad事件中检查OpenArgs ,并将TabCtontrol的值设置为您要显示的页面的索引,如下所示:

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

I made an example accdb to show the complete setup. 我做了一个示例accdb来显示完整的设置。

In case if anyone is looking for code where you have a button on another form and want to open Main form from that and also take user to a particular Tab. 如果有人在寻找代码,你在另一个表单上有一个按钮,并希望从中打开主表单,并将用户带到特定的选项卡。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM