passing an element name using a variable

Avagut

I have a multi page element on a MS Access form and I am trying to use GetArgs to identify which page to open using the below code. Could anyone assist me with how to convert the page name to a format MS Access will accept?

Dim WrdArray() As String
If Not IsNull(Me.OpenArgs) Then
    LoadAndLocation = Me.OpenArgs
    WrdArray() = Split(LoadAndLocation, "|")
    OriginalPage = WrdArray(1) 'This works and results in the correct page name eg Fina
    Me.OriginalPage.SetFocus 
End If
Tim Williams

Not that familiar with Access, so there's maybe a cleaner way to do it, but I think this is what you're looking for.

Private Sub Tester()

    SetTabByName Me.TabCtl0, "Second" 'set by Caption

    SetTabByName Me.TabCtl0, "Page1"  'set by Name

End Sub


'Set tab control active page: match on tab name *or* caption...
Sub SetTabByName(tabCtrl As TabControl, sVal As String)
    Dim x As Long
    For x = 0 To tabCtrl.Pages.Count - 1
        If tabCtrl.Pages(x).Name = sVal Or _
           tabCtrl.Pages(x).Caption = sVal Then
            tabCtrl.Value = x
            Exit For
        End If
    Next x
End Sub

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related