how can i hide a page in a tab control using an option group

G

Guest

I'm using Access 2000 and am trying to hide a page within a tab control from
a selection from an option group. For example, my option group contains
three choices: Employee Only, Dependents Only, or Both. If I've selected
either Dependents Only or Both, then I'd like to continue seeing the tab
Dependent Info tab. However, if I select Employee Only, then I want to hide
the Dependent Info tab. I've tried the following; however, when I scroll
through my records the Dependent Info tab is not consistently hidden when
need be.

Private Sub OptFrmAppType_AfterUpdate()
Select Case OptFrmAppType.Value
Case 1 'Employees
Me.EmployeeInfo.Visible = True
Me.DependentInfoTab.Visible = False
Case 2 'Dependents
Me.DependentInfoTab.Visible = True
Me.EmployeeInfo.Visible = True
Case Else 'Both
Me.EmployeeInfo.Visible = True
Me.DependentInfoTab.Visible = True
End Select
End Sub
 
V

Van T. Dinh

You need to use the Form_Current Event also. Presumably, you have a Field
in the Form's RecordSource indicating whether there are "Dependents" or not,
use the value of this to show / hide the "Dependent Info" page.
 
G

Guest

Van,

I'm using the option group to identify when I have dependents by
selecting either "Dependents Only" or "Both". My option group is located
above my tab control pages in the detail section. "Employee Only" = 3,
"Dependents Only" = 2 and "Both" = 3 within my option group. Those numbers
are stored in a table under a field called "AppType". Is this what you mean?

How do I go about using the Form_Current Event? Would I place the same
code below in it?

Danny
 
V

Van T. Dinh

If you want the Tab pages to become visible / invisible when you change the
CurrentRecord, there must be something in the "newly-moved-to" CurrentRecord
(of the Form's Recordset) for you (and Access) to know whether to show /
hide the Tab pages.

Is AppType a Field *in the Form's Recordset* that has different value for
different Record which corresponds to whether the Tab pages should be
visible / invisible? If this is the case, you can use the value of this
Filed to manipulate the Tab pages.

The code will be similar to what you post but instead of the OptionFrame,
you use the Field I mentioned above.
 
P

Paul Overway

Assuming that the code that hides/shows the needed tabs is in the
AfterUpdate event for the frame/option group...you just need to call the
AfterUpdate for option group within Form_Current, i.e.,

Sub Form_Current()

fraOptions_AfterUpdate

End Sub
 
V

Van T. Dinh

Paul

This works if the fraOptions is bound to a Field in the Form's Recordset
(and this changes when the CurrentRecord changes). If the fraOptions is
unbound, calling the fraOptions_AfterUpdate won't do anything for the Pages
in the TabControl since they are already correct.

I am not sure whether the fraOptions is bound or not from the O.P.'s posts
so far.
 

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