Visibility 2

T

Tom

Maybe I'm not expessing myself adequately. My form has many "Tabs". I want
to only have one "Visible" based on the information contained in a
"Department" field on the main section of the form. Several different
departments, each with a related tab for data.

Example, Engineering in department field, only engineering tab shows....
 
B

Beetle

I would suggest using a combo box for selecting the department (if you're
not doing that already), then you could code the After Update event of the
combo box to show or hide tabs based on what is selected.

For example, suppose you have a combo box named cboDepartment and
a tab control named TabCtl0 with Engineering on the first tab and Science
on the second tab. The code might look like;

Private Sub cboDepartment_AfterUpdate

Me.TabCtl0.Pages(0).Visible = Me.cboDepartment = "Engineering"
Me.TabCtl0.Pages(1).Visible = Me.cboDepartment = "Science"

End Sub

The Page index is zero based, so the first tab is Page(0), the second is
Page(1), etc.

The reason I suggest a combo box is that if you use a text box and the
user misspells something, you may end up with none of your tabs visible.
 
T

Tom

Beetle.... Works Almost perfectly. If I change the description in my
department drop down, the appropriate tab becomes visible. However, in the
older records my department value is already established and the tabs do not
change as I go from department to department.....(unless I change the value,
and go back)

Thoughts??
 
B

Beetle

Try duplicating the code in your form's Current event, then test
to make sure it works like you want.
 
B

Beetle

Set the focus back to the combo box before you hide the tabs;

Private Sub Form_Current

Me.cboDepartment.SetFocus
Me.TabCtl0.Pages(0).Visible = Me.cboDepartment = "Engineering"
Me.TabCtl0.Pages(1).Visible = Me.cboDepartment = "Science"

End Sub
 
T

Tom

That did it...

Thnax Mucho

Beetle said:
Set the focus back to the combo box before you hide the tabs;

Private Sub Form_Current

Me.cboDepartment.SetFocus
Me.TabCtl0.Pages(0).Visible = Me.cboDepartment = "Engineering"
Me.TabCtl0.Pages(1).Visible = Me.cboDepartment = "Science"

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

Similar Threads

Db design review 9
Training Records Database 3
Select Only Some Records 4
Departmental Database Design 2
Efficient Table Design Questions 3
Combine databases 3
Forms and 2 tables 3
Please help 1

Top