How do I keep the tabs of the tabbed pages at the top of long form

D

dc

I have a multi-tabbed form. The forms on each page are long enough so that I
always have to scroll up to see the tabs--it's annoying! Is there a way to
"freeze" the tabs at the top?

Thank you!!
Dara
 
M

Maurice

No you cannot freeze them. You have to resize the entire tabcontrol so the
tabs stay visible without having to scroll. However ther might be one trick
you might try and that is place togglebuttons in the formheader which contain
the names of the tabs and make those active based on what tab has the focus.
I know takes a lot of work but it's just a thought ;-)
 
D

dc

Interesting idea. I dont know much about "focusing" but I'll see what I can
figure out. THANK you for responding!
~dc
 
N

NKTower

I've done something very similar. Here's a sketch that should get you going.


Step 1: In form designer - create a dummy form that is the size of the
"aperture" that you want the subforms to be restricted to. The subforms will
scroll within this aperture while the main part of the form with the tabs
won't move. Let's say that you have 10 tabs, so for my example, I'll call
this form "sfm_10tabs. It does not need to contain any controls - just a
blank form. However, I usually put a label on it with the caption "10 tabs
PlaceHolder" and then make the label VISIBLE=FALSE so that it won't ever be
visible at run-time. sfm_10tabs is a "PlaceHolder" needed to satisfy the
form designer and VBA when we write code to change it at run-time.

Step 2: Create a set of subforms, one for each of the tabs. I'll call them
sfm_Tab_0, sfm_Tab_1, etc. If necessary set the record source to a query
that references the data in the main form. We are going to do the
Parent/Child linking ourselves. Alternatively, bind the subform to the main
form's row source, if appropriate.

Step 3: On your "main" form that is to contain the tab control...
a) Create your tab control with the 10 tabs. Note that internally value of
the tab control will be 0 to 9.
b) Make the the height of the page that the tab control "owns" the smallest
you can since we are only going to use the tab control for selection
purposes. Let's call the control tab_10tabs
c) drag and drop sfm_10tabs onto your main form and position it immediately
below the tab control.
d) Set the scroll properties of sfm_10tabs as needed - VERTICAL, HORIZONTAL,
BOTH as needed.
e) Now a bit of VBA code...


Public Sub tab_10tabs_Change()
Select Case tab_My10tabs.Value
Case 0 ' first tab
Me.sfm_10tabs.SourceObject = "sfm_Tab_0"
Case 1
Me.sfm_10tabs.SourceObject = "sfm_Tab_1"
...
Case 9
Me.sfm_10tabs.SourceObject = "sfm_Tab_9"
End Select
' next line only necessary if simulating Parent/Child
Me.sfm_10tabs.Requery
End Sub


Notes:

1) For a main tab control that had a lot of pages, I found this technique to
be much better than having controls on the pages as Access loads all of the
data whether the not-yet-visible pages are going to be used or not. This
mechanism only loads a 'page' when it is needed. It also circumvented a
problem with the number of controls that may be on a form.
2) Since you only have one 'sfm_Tab_X' loaded at any given time, you can NOT
see stuff that is normally on a different page. You will have to work around
that by either having the "other" data invisible on the subform, or by going
to the database record directly.
3) As [art of your main's Form_Open() event, set tab_10tab.Value = 0 and set
sfm_10tabs.SourceObject="sfm_Tab_0" so that you start with something on the
screen.
4) If you allow creating records on the subforms, and are mimicing the
Parent/Child mechanism, you will have to get the values from the parent form
and insert them into the record for the subform - do the insertion as part of
the subform's "Before_Insert" event.
 

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