Tabbed Form Design

G

G2

How do I create a tabbed form, where the tab names and number of tabs will
change based on the outcome of a "group-by" query? (or the unique values in
one field of a table). Or am I asking too much from a tabbed form?
 
B

Brendan Reynolds

G2 said:
How do I create a tabbed form, where the tab names and number of tabs will
change based on the outcome of a "group-by" query? (or the unique values
in
one field of a table). Or am I asking too much from a tabbed form?


You can add tabs to a form programmatically, but the form must be open in
design view. It's generally better to create the maximum number of tabs you
will need at design time, and toggle their visibility at run time, which
does not require the form to be in design view.

Here's an example that gets the number of tabs and their captions from text
boxes on the form ...

Private Sub cmdBuildTabs_Click()

Dim lngPages As Long
Dim lngLoop As Long
Dim varCaptions As Variant

lngPages = CLng(Me.txtNumPages)
varCaptions = Split(Me.txtTabNames, " ")

For lngLoop = 0 To Me.tabTest.Pages.Count - 1
Me.tabTest.Pages(lngLoop).Visible = False
Next lngLoop
For lngLoop = 0 To lngPages - 1
Me.tabTest.Pages(lngLoop).Visible = True
Me.tabTest.Pages(lngLoop).Caption = varCaptions(lngLoop)
Next lngLoop

End Sub
 

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