Tab Pages Visible only when certain criteria met

  • Thread starter Thread starter SarahEGray
  • Start date Start date
S

SarahEGray

I have a database and have set it up so that I have 6 tab pages. The first
contains general information and always needs to be visible. I have radio
buttons set which have the same headings as the tab pages and I want to click
the radio button and make the tab page visible.

Example:
General Data is open but radio button 2 is checked, this record should now
show the General Data page and page 2.

Any help would be very much appreciated.
 
Private Sub Frame5_AfterUpdate()
Dim lngLoop As Long

For lngLoop = 0 To (Me.TabCtl0.Pages.Count - 1)
Me.TabCtl0.Pages(lngLoop).Visible = False
Next lngLoop

Me.TabCtl0.Pages(Me.Frame5).Visible = True

End Sub

(This assumes that you set the values associated with each radio button to
correspond to the number in the Pages collection. By default, Page1 on the
tab corresponds to element 0 in the Pages collection. That means that you'd
want radio button 2 to return 1, not the default 2.)
 
I have successfull managed to open up the tab pages by clicking the button
using the following code: -

Private Sub Abermed_Check_Box_Click()
If Abermed_Check_Box.Value Then
Me.Personal_Details.Visible = True
Me.Abermed.Visible = True
Me.Abermed.SetFocus
Me.Redeployment.Visible = False
Me.Work_Performance.Visible = False
Me.Grievance_and_Dignity.Visible = False
Me.Disciplinary.Visible = False
End If

I have done this for each tab but I cannot now figure out how to ensure that
each tab stays open once checked. If I check another button it closes the
first and opens the new one in its place.

I am also trying to figure out how to re-hide them if I uncheck the button.
Again any help would be much appreciated.
 
You said radio buttons, which by convention means that only a single one
should ever be selected. If you want multiple to be selected, you should be
using check boxes, and your code implies that's actually what you are using.

Assuming you've got 6 checkboxes named Personal_Details_Check_Box,
Abermed_Check_Box, Redeployment_Check_Box, Work_Performance_Check_Box,
Grievance_and_Dignity_Check_Box and Disciplinary_Check_Box, the code for
each need only be:

Private Sub xxx_Check_Box_Click()
If xxx_Check_Box.Value Then
Me.xxx.Visible = True
Me.xxx.SetFocus
End If
End Sub

(Hide all 6 in the form's Load event)
 
Sorry I did have Radio buttons to start and then realised my error so changed
them to Check boxes.

I basically want each tab to open up if the box is checked and hide again if
unchecked, it may be that I have 2 boxes checked i.e. Redeployment and
Disciplinary for one specific record but at the moment if I check the box it
opens for every record and then if I check another it closes the original tab
and opens the new one in its place.
 
There's nothing in what I suggested that would close a tab once it's open,
so perhaps you'll have to post the actual code you're using.
 
At the moment if I select a check box then it opens for every record. I want
every record to be individual so that each case can record only what is
relevant to the person in that record.

The tabs stay open when I am in the form, it is only once I close the form
so when I re-open the form the only tab open is the employee one.

I really need it to allow me to select the check boxes for each category,
and then save it as per each record, i.e. Employee tab, Abermed tab for
record 1 then Employee tab, Abermed tab, Redeployment tab for record 2.

Any more suggestions are very welcome.
 
Sounds as though you're using an unbound check box (i.e.: it's not bound to
a field in the form's recordset). That's how unbound controls work: whatever
you do to one occurrance applies to all occurrances.
 
Back
Top