Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command Button to navigate pages and tabs

Status
Not open for further replies.

kokiri

Technical User
Feb 18, 2003
51
US
I'm new with forms.

I have couple of forms and I need to be able to navigate different forms, pages, and tabs based on which command button is clicked.

Form1: Page1...page5, page3, tab1...tab10, cmd1...cmd3
Form2: Page1...Page5, page3, tab1...tab10, cmd1...cmd3

Tried several options but so far no luck. What do you recommend?

Thanks.
 
How are ya kokiri . . .

Sounds like you need a [blue]Switchboard[/blue]!

From the database window:

Tools - Database Utilities - [blue]Switchboard Manager[/blue]

Calvin.gif
See Ya! . . . . . .
 
Hi TheAceMan1,

I tried Switchboard already, but no luck so far. It let you open the form but I wasn't able to cursor to focus on specific tab#.

Can you be provide detail step.

Thanks.
 
I am not sure what you are asking. I think you want to open a form and go to a specific page on a tab control. This allows me to specify a form name, a tab control name, and a page number.
Code:
Public Sub subOpenTabForm(strFormName As String, strTabCntrlName As String, intPage As Integer)
  DoCmd.OpenForm strFormName
  Forms("frmTabTest").Controls(strTabCntrlName).Pages(intPage).SetFocus
End Sub
Here is an example to test it. It opens the form to the second page (0 index).

Public Sub testTabForm()
Call subOpenTabForm("frmTabTest", "tbCtrlTest", 1)
End Sub

Provide more details, if this does not help.
 
Oops. Should read
Forms(strFormName).Controls(strTabCntrlName).Pages(intPage).SetFocus
 
This will give you a lot of flexibility. Again I assume that you want to click a button and open a form, and go to a specific page on a tab control. I assume you have only one tab control on a form.
1. Make a form with your command buttons.
2. In the tag property of each command button list the form name and the page name seperated by a semicolon
ex. myTabForm;myPage
3. On the click event put this code for each command button.
Code:
Private Sub cmdOne_Click()
  Call splitTag(activeControl.tag)
End Sub
4. In a module include these two procedures
Code:
Public Sub splitTag(strTag As String)
  Dim aFormAndPage() As String
  aFormAndPage = Split(strTag, ";")
  Call subOpenTabForm(aFormAndPage(0), aFormAndPage(1))
End Sub

Public Sub subOpenTabForm(strFormName As String, strPage As String)
  Dim myControl As Access.Control
  DoCmd.OpenForm strFormName
  For Each myControl In Forms(strFormName)
    If myControl.ControlType = acTabCtl Then
Forms(strFormName).Controls(myControl.Name).Pages(strPage).SetFocus
       Exit Sub
    End If
  Next myControl
End Sub

Now you can put a command button anywhere in your project, and assign the tag property to open a form and a page on a tab control.
 
kokiri . . .

Which ever method you use, [blue]you have to tell each form what Tab Page & Control to goto.[/blue] . . . So in the [blue]Load[/blue] event of each form having a [blue]Tab Control[/blue]:
Code:
[blue]   Me![purple][b]TabControlName[/b][/purple].Pages("[purple][b]PageName[/b][/purple]").SetFocus
   Me![purple][b]ControlName[/b][/purple].SetFocus[/blue]

Calvin.gif
See Ya! . . . . . .
 
The TheAceMan1 & MajP,

Thanks for the help. It works!

Thanks bunch!


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top