Better way of navigating in a tab control with many tabs?

T

Tammy

Hi,

I'm not sure if this can be done, but I have a user who has a tab control
with many tabs. Instead of having to use the "next" and "previous" buttons of
the tab control to navigate between tabs, is there a way to add a "menu" of
some kind that they can display to get a list of tabs, and when a selection
is made, it will jump them to that tab?

We are using Access 2007.

Thanks for any suggestions!
 
J

Jeff Boyce

Tammy

By default ("out of the box"), tab controls come with, well, "tabs". I
guess I don't understand why you'd want to ADD a way to select a tab when
you could just have the users click on the tab they want.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
K

Kay

I am a strickly self taught user so please look past my incorrect verbage of
access.
I am also not sure of your capabilities with access, so I will assume your a
beginner.

The following works for me...

1 First create a unbound combo box with two columns.

2 Using the wizard you will select "I will type the values I want"

3 The first column should have the name of each tab (usually Page272,
Page273
and ect.)

4 The second column should be whatever refence you want to name the
tabs.(Employees Page, Managers Page, Vendors Page)

5 When you hit next in the combo wizard, you will select Col1 as the bound
column.

6 Now it will ask you to name it, for the purposes of the following code,
use "TabControl" Confirm that its name is TabControl when you are done
creating the combo box or the code will not work

7 Open the properties of the combobox and change the column width to 0, so
it only displays the reference column.

8 Type the following on the combobox's afterupdate event "=GoToTab()"

9 Lastly: Create a module by copying and pasting the following code and save

Let me know how it works out

Function GoToTab()
On Error GoTo GoToTab_Err

If (IsNull(Screen.ActiveControl)) Then
Exit Function
End If
TempVars.Add "GoToTab", "[Screen].[ActiveControl]"
If (CurrentProject.IsTrusted) Then
Screen.ActiveControl = Null
End If
DoCmd.GoToControl TempVars!GoToTab
TempVars.Remove "GoToTab"


GoToTab_Exit:
Exit Function

GoToTab_Err:
MsgBox Error$
Resume GoToTab_Exit

End Function
 
C

crazyaccessprogrammer

Comment:
Usually when I find myself in a situation where the number of pages on a tab
control is getting excessive, it's because the form itself isn't focused
enough. This sorta gets into database design in general... one thing you want
to have for your users is a clear purpose for each form. The clearer the
purpose the better the form will 'flow.'

Solutions
The whole problem is that a tab control contains a lot of pages. For the
sake of keeping things simple, my tab control will have only 3 pages.

Here is how I set up my controls on a sample form. You will have to
substitute names of controls and their captions using those in your existing
form.

PAGES of a TAB CONTROL PROPERITES:

Page 1
Name: Page0
Caption: General

Page 2
Name: Page1
Caption: Sales

Page 3
Name: Page2
Caption: Inventory

LISTBOX PROPERTIES

Name: MyListBox
ControlTipText: Use Ctrl or Shift To Select Multiple Items
Multi-Select: Extended
Row Source Type: Value List
Row Source: "Page0";"General";"Page1";"Sales";"Page2";"Inventory"
Column Count: 2
Column Widths: 0";1"
Column Heads: No

MyListBox AFTERUPDATE EVENT:

' Declare Variables
Dim intCurrentRow As Integer

' Main Loop
For intCurrentRow = 0 To Me.MyListBox.ListCount - 1

If Me.MyListBox.Selected(intCurrentRow) = True Then

' Make The Tab Control Page Visible
Me.Form.Controls.Item(Me.MyListBox.ItemData(intCurrentRow)).Visible = True

Else

' Make The Tab Control Page Invisible
Me.Form.Controls.Item(Me.MyListBox.ItemData(intCurrentRow)).Visible =
False

End If

Next intCurrentRow

SETTING DEFUALT PAGES TO VISIBLE/INVISIBLE WHEN FORM LOADS
Say you want only Page0 and Page2 visible when the form is opened. Paste the
following code into the form's OnOpen Event

' Declare Variables
Dim intCurrentRow As Integer

For intCurrentRow = 0 To Me.MyListBox.ListCount - 1

Select Case intCurrentRow

Case 0, 2
Me.MyListBox.Selected(intCurrentRow) = True

End Select

Next intCurrentRow

Call MyListBox_AfterUpdate




You can modify Case 0,2 for whatever pages you want visible when the form
loads.
 
T

Tammy

Hi crazyaccessprogrammer,

Thanks so much for taking the time to respond. I apologize that I do not
understand programming, so am not sure if what you have proposed is what I am
looking for. I really hope the code was something you copied and pasted, and
didn't write out from scratch.

There are many tabs on the tab control because the form *is* extremely
focused. The database isn't as simple as sales, customers and products. It
tracks legal cases, and all aspects of the cases. Each tab represents an
aspect of the case. Because there are so many "parts" to legal cases, and the
information is broken down logically by using a tab for each purpose of the
case, I was looking for a way to navigate easily to tabs that appear at the
end (or middle), instead of using the "next" arrow to switch between tabs.

I haven't seen anything out of the box that does this - but, I know there
are a lot of databasers out there with tricks up their sleeves, so thought
I'd post a question.

All of the tabs of the tab control should appear at all times. I was just
wondering if there could be a quicker way to navigate between tabs on a tab
control - other than the "next" and "previous" arrows.

Because I am not a programmer, I think this question falls under the "nope,
can't do it, you have to use the arrows to navigate" category. Thanks, again,
for taking the time to respond.
 
J

Jeff Boyce

Tammy

There seems to be a difference of definition...

You wrote "... all aspects of the case", while <crazyaccessprogrammer> wrote
"focused". Those two aren't consistent, are they?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
T

Tammy

Hi Jeff,

From where I am coming, my user has a database that collects a lot of
information -that information is stored in many tables - each related to a
specific purpose (all aspects of the cases). In order to see all of this
information in one place, a form has been set up, using tabs to keep the
information organized for the end users (each tab focuses on an individual
aspect of the case).

I was just trying to find out if there was a way to navigate a tab control
quicker. I apologize if terms I am using seem to contradict what other users
are offering. I get a lot of very useful information from this site, and do
not want to create any conflicts. It was just a "wondering" question.

Thanks, Jeff!
 
C

CrazzyAccessProgrammer

I believe what I wrote provides a solution for you. The best way to
understand it would be to create a brand new form and create the two controls
(Tab Control and Listbox) I described in my original post setting their
properties in the way I described and cutting/pasting the code in the
listbox's AFTERUPDATE event and the form's ONOPEN event. Then run the form
and see how it works.

The code isn't terribly difficult to understand and adapt to any tab control
with any number of pages.
 
T

Tammy

Hi Kay,

Nothing showed earlier today when I tried accessing your response. Thank you
very much for taking the time to answer my post. I will try your excellent
suggstion and let you know how it goes. Thanks very much!

Kay said:
I am a strickly self taught user so please look past my incorrect verbage of
access.
I am also not sure of your capabilities with access, so I will assume your a
beginner.

The following works for me...

1 First create a unbound combo box with two columns.

2 Using the wizard you will select "I will type the values I want"

3 The first column should have the name of each tab (usually Page272,
Page273
and ect.)

4 The second column should be whatever refence you want to name the
tabs.(Employees Page, Managers Page, Vendors Page)

5 When you hit next in the combo wizard, you will select Col1 as the bound
column.

6 Now it will ask you to name it, for the purposes of the following code,
use "TabControl" Confirm that its name is TabControl when you are done
creating the combo box or the code will not work

7 Open the properties of the combobox and change the column width to 0, so
it only displays the reference column.

8 Type the following on the combobox's afterupdate event "=GoToTab()"

9 Lastly: Create a module by copying and pasting the following code and save

Let me know how it works out

Function GoToTab()
On Error GoTo GoToTab_Err

If (IsNull(Screen.ActiveControl)) Then
Exit Function
End If
TempVars.Add "GoToTab", "[Screen].[ActiveControl]"
If (CurrentProject.IsTrusted) Then
Screen.ActiveControl = Null
End If
DoCmd.GoToControl TempVars!GoToTab
TempVars.Remove "GoToTab"


GoToTab_Exit:
Exit Function

GoToTab_Err:
MsgBox Error$
Resume GoToTab_Exit

End Function



Tammy said:
Hi,

I'm not sure if this can be done, but I have a user who has a tab control
with many tabs. Instead of having to use the "next" and "previous" buttons of
the tab control to navigate between tabs, is there a way to add a "menu" of
some kind that they can display to get a list of tabs, and when a selection
is made, it will jump them to that tab?

We are using Access 2007.

Thanks for any suggestions!
 
T

Tammy

Thanks, again CrazzyAccessProgrammer! I will give it a try. I was finally
able to "see" Kay's suggestion - which may be the same as yours - I'll take a
closer look and try them both, if necessary. Thanks so much for your time.
 
C

CrazzyAccessProgrammer

No problem at all happy to help =)

I use the code I gave you on some of my form's but for different reasons.
For me, some user's have permission to access a form, but not permission to
see certain pages of a tab control. I use a variation of the code I gave you
to accomplish that. What I gave you was really a simplified version of what I
use because your situation is simplier. Anyway, good luck.
 
K

Kay

Sorry Tammy, I forgot you must name the object in a module. This is the
corrected code.

Function GoToTab()
On Error GoTo GoToTab_Err

With CodeContextObject
If (IsNull(.TabControl)) Then
Exit Function
End If
TempVars.Add "GoToTab", "[TabControl]"
Screen.ActiveControl = Null
DoCmd.GoToControl TempVars!GoToTab
TempVars.Remove "GoToTab"
End With


GoToTab_Exit:
Exit Function

GoToTab_Err:
MsgBox Error$
Resume GoToTab_Exit

End Function
 
K

Kay

Sorry Tammy I forgot that you must name the object in a module, the following
code is corrected.

Function GoToTab()
On Error GoTo GoToTab_Err

With CodeContextObject
If (IsNull(.TabControl)) Then
Exit Function
End If
TempVars.Add "GoToTab", "[TabControl]"
Screen.ActiveControl = Null
DoCmd.GoToControl TempVars!GoToTab
TempVars.Remove "GoToTab"
End With


GoToTab_Exit:
Exit Function

GoToTab_Err:
MsgBox Error$
Resume GoToTab_Exit

End Function
 
T

Tammy

Hi Kay,

I am running through your instructions and receive this message when I try
to choose something from the combo box:

"There is no field named 'Screen.ActiveControl' in the current record."

I am a total beginner when it comes to programming, so is it possible that I
copied and pasted the code to the wrong place? I copied and pasted the code
in the window that opened when I used the "View Code" button from the Ribbon
(Microsoft Visual Basic). Was anything specific supposed to be selected on
the form before I hit the View Code button? If I was supposed to add
something to the code, could you walk me through that?

Thanks, again, for your help!




Kay said:
I am a strickly self taught user so please look past my incorrect verbage of
access.
I am also not sure of your capabilities with access, so I will assume your a
beginner.

The following works for me...

1 First create a unbound combo box with two columns.

2 Using the wizard you will select "I will type the values I want"

3 The first column should have the name of each tab (usually Page272,
Page273
and ect.)

4 The second column should be whatever refence you want to name the
tabs.(Employees Page, Managers Page, Vendors Page)

5 When you hit next in the combo wizard, you will select Col1 as the bound
column.

6 Now it will ask you to name it, for the purposes of the following code,
use "TabControl" Confirm that its name is TabControl when you are done
creating the combo box or the code will not work

7 Open the properties of the combobox and change the column width to 0, so
it only displays the reference column.

8 Type the following on the combobox's afterupdate event "=GoToTab()"

9 Lastly: Create a module by copying and pasting the following code and save

Let me know how it works out

Function GoToTab()
On Error GoTo GoToTab_Err

If (IsNull(Screen.ActiveControl)) Then
Exit Function
End If
TempVars.Add "GoToTab", "[Screen].[ActiveControl]"
If (CurrentProject.IsTrusted) Then
Screen.ActiveControl = Null
End If
DoCmd.GoToControl TempVars!GoToTab
TempVars.Remove "GoToTab"


GoToTab_Exit:
Exit Function

GoToTab_Err:
MsgBox Error$
Resume GoToTab_Exit

End Function



Tammy said:
Hi,

I'm not sure if this can be done, but I have a user who has a tab control
with many tabs. Instead of having to use the "next" and "previous" buttons of
the tab control to navigate between tabs, is there a way to add a "menu" of
some kind that they can display to get a list of tabs, and when a selection
is made, it will jump them to that tab?

We are using Access 2007.

Thanks for any suggestions!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top