Need Help with Set Focus Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Maybe there's a better way to do this - but here's what I've developed so far.

I've got a Main Form that's got a ton of fields. Good thing is that the
fields can be arranged logically into categories and sub categories. Bad
thing is that each main category of information has several subcats...

So I've set up five labels with category headings on the form.

I'd like to set it up so that when the user clicks a label, the
corresponding tab control will be displayed. Each of the five corresponding
tab controls are 'stacked' on top of each other so they display in the same
location on the form.

Unfortunately, it isn't working so well.

The On Click event for each label, looks something like this:

Me.(page).SetFocus
Me.(tabB).Visible = False
Me.(tabC).Visible = False
Me.(tabD).Visible = False
Me.(tabE).Visible = False
Me.(tabA).Visible = True
Me.Repaint

The results aren't good. When clicking between the labels, I have to click
two or more times to display the fields on the tab, and even then the tabs at
the top of the tab control don't show up.

Any suggestions?

Thanks,

Scott A
 
Why not just use the tab control as it was intended. The user clicks
on the tab and that one is displayed. I'm pretty sure you can set the
style to look like buttons if you wish as well. It almost sound like
you have one tab control with one page in it - several times on the
form. If so, just add more pages to one.
 
Because then I'd have 18 tabs on one control and the correlation between the
categories and subcategories would be lost. It's not that I want the tab
controls to look like buttons - I want to limit the number of fields
displayed on the screen based on the category selection.
 
Because then I'd have 18 tabs on one control and the correlation between the
categories and subcategories would be lost. It's not that I want the tab
controls to look like buttons - I want to limit the number of fields
displayed on the screen based on the category selection.

<puzzlement> Then put only the desired controls on each tab.

John W. Vinson [MVP]
 
<puzzlement> Then put only the desired controls on each tab.

John W. Vinson [MVP]


Maybe "we're" just not seeing what you are trying to accomplish.
Perhaps a different or further explanation is required?
 
The 5 top-level labels are supposed to work like a tab control - they
show/hide the subcategory controls based on which one you select.

The subcategory controls are each displayed on multi-tab tab controls as well.

I'd be in good shape if it were possible to imbed tab controls on other tab
controls, then i'd just use a tab control for the top-level categories, but
as far as I can tell it doesn't seem possible -- I can put fields and
sub-forms on a tab control, but when I try add tab controls to an existing
page, it just creates a whole new tab control...

Would it be better then to put all of the sub-category fields on a single
tab control and use control buttons to show/hide relevant tabs?
 
The 5 top-level labels are supposed to work like a tab control - they
show/hide the subcategory controls based on which one you select.

The subcategory controls are each displayed on multi-tab tab controls as well.

I'd be in good shape if it were possible to imbed tab controls on other tab
controls, then i'd just use a tab control for the top-level categories, but
as far as I can tell it doesn't seem possible -- I can put fields and
sub-forms on a tab control, but when I try add tab controls to an existing
page, it just creates a whole new tab control...

Would it be better then to put all of the sub-category fields on a single
tab control and use control buttons to show/hide relevant tabs?


I think so.
Perhaps you could use the Tag property of each tab to give a "top"
level catagory id to them. So maybe 6 out of the 18 have a Tag
property of "Group1", another 6 as "Group2" and so on. Instead of
using labels as buttons, perhaps use toggle buttons - actually maybe
as an Option Group so that only one can be chosen at a time. Create a
single proceedure that loops through all tabs and hides/unhides the
tab based on the toggle button that was clicked. Example (not an in
depth one)

Private Sub ShowTabs(TagGroup As String)
Dim pge as Page
For Each pge In Me!TabControl.Pages
If pge.Tag = TagGroup Then
pge.Visible = True
Else
Pge.Visible = False
End If
Set pge=Nothing
End Sub

Then in the Option Group AfterUpdate event use:

Select Case Me!OptionGroup
Case 1
ShowTabs "TagGroupString1"
Case 2
ShowTabs "TagGroupString2"

and so on...

Maybe?
 
Back
Top