Results 1 to 8 of 8
  1. #1
    jpg250 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    26

    Open a specific sub-Form from a different Form

    The Main Form in my database (the one that starts when opened) needs to call a tabbed Maintenance Form, which has several Pages with sub-Forms. How can I open a specific Page in the Maintenance Form from the Main Form. Please note that it is not always the same Page that needs to be opened.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    How about using the OpenArgs argument to pass the tab number or name to the Maint Form and then use the OnLoad event of the Maint Form to select the tab you want?
    http://www.baldyweb.com/OpenArgs.htm

  3. #3
    jpg250 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    26
    Thanks RG. I'll try that.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    You're welcome. Let us know how you make out.

  5. #5
    jpg250 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    26
    Hi RG. I've got the OpenArgs working to pass in the name of the page I want to set focus to, which is of course a String. I'm stumped now in how to convert that string into an object to which I can set focus. Tried this, but it didn't work: (I'm new to VBA, as you can probably tell)

    Dim strOpenArgs() As String
    Dim pageToOpen As String
    Dim tabpage() As Page
    Dim i As Integer

    If Not IsNull(Me.OpenArgs) Then
    strOpenArgs = Split(Me.OpenArgs, ";")
    pageToOpen = strOpenArgs(0)
    i = 0
    For Each tabpage In Me.TabCtl0

    If tabpage(i).Name = pageToOpen Then
    tabpage(i).SetFocus
    End If
    i = i + 1

    End
    End If

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Are you passing a "Name" or a Number?
    The code would be: Me.YourTabControlName.Pages(pageToOpen).SetFocus

  7. #7
    jpg250 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2013
    Posts
    26
    Good news.
    Yes, I was passing a Name. Changed it to a number and using your code it now works.
    Thank you very much.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Excellent! Glad we could help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. open specific form after login
    By manojsikar1 in forum Forms
    Replies: 1
    Last Post: 11-21-2012, 08:54 AM
  2. Open form on specific record
    By iky123 in forum Forms
    Replies: 1
    Last Post: 04-11-2012, 09:56 AM
  3. Open form to specific record
    By Two Gun in forum Forms
    Replies: 7
    Last Post: 11-09-2011, 10:00 AM
  4. Open Form to Specific Record
    By batowl in forum Forms
    Replies: 1
    Last Post: 04-08-2011, 10:10 AM
  5. Open to specific form
    By ecpike in forum Forms
    Replies: 2
    Last Post: 06-12-2009, 08:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums