use option control group to hide or display a subform

G

Guest

I have an option control group with three selections; 1, 2 and 3. I also
have three subforms stacked at the same location on a main form.

I wish to have my selection in the option control group control the hiding
or displaying of subforms. That is, when I select option 1, subform 1 will
be visible and subforms 2 and 3 will be hidden. When option 2 is selected,
subform 2 will be visible and subforms 1 and 3 will be hidden. When option 3
is selected, subform 3 will be visible and subforms 1 and 2 will be hidden.

I am also assuming that since 1 is my default selection that on subform 1
the properties for visible should be 'yes' and for subforms 2 and 3 the
property should be no.

I have read MS Article Q210600 " How to Use a Button to Hide and Display a
Subform in Access" and understand it but can't convey the logic to an option
control group. Help is greatly appreciated!
 
K

Ken Snell [MVP]

Use the AfterUpdate event of the option group to make the subform controls
visible/invisible, depending on the value of the option group.
 
G

Guest

I've tried this coding which gets me part way there but ... can you give me a
code example of what you mean? I had tried the AfterUpdate command
previously. Much thanks!!

Private Sub Structure_type_Click()

Me!Structure_type = 1
Me![Bridge superstructure data subform].Visible = _
Not Me![Culvert structure data subform].Visible
Me!Structure_type = 2
Me![Culvert structure data subform].Visible = _
Not Me![Bridge superstructure data subform].Visible
Me!Structure_type = 3
Me![Sign/Wall structure data subform].Visible = _
Not Me![Sign/Wall structure data subform].Visible

End Sub
 
K

Ken Snell [MVP]

I'm guessing at which subforms are to be visible for each value of the
option group, but this should give you one idea of how to structure the
code.

Private Sub Structure_type_AfterUpdate()
Select Case Me.Structure_type.Value
Case 1
Me![Bridge superstructure data subform].Visible = True
Me![Culvert structure data subform].Visible = False
Me![Sign/Wall structure data subform].Visible = False
Case 2
Me![Bridge superstructure data subform].Visible = False
Me![Culvert structure data subform].Visible = True
Me![Sign/Wall structure data subform].Visible = False
Case 3
Me![Bridge superstructure data subform].Visible = False
Me![Culvert structure data subform].Visible = False
Me![Sign/Wall structure data subform].Visible = True
End Select
End Sub
--

Ken Snell
<MS ACCESS MVP>




Hermie71 said:
I've tried this coding which gets me part way there but ... can you give
me a
code example of what you mean? I had tried the AfterUpdate command
previously. Much thanks!!

Private Sub Structure_type_Click()

Me!Structure_type = 1
Me![Bridge superstructure data subform].Visible = _
Not Me![Culvert structure data subform].Visible
Me!Structure_type = 2
Me![Culvert structure data subform].Visible = _
Not Me![Bridge superstructure data subform].Visible
Me!Structure_type = 3
Me![Sign/Wall structure data subform].Visible = _
Not Me![Sign/Wall structure data subform].Visible

End Sub

Ken Snell said:
Use the AfterUpdate event of the option group to make the subform
controls
visible/invisible, depending on the value of the option group.
 
K

Ken Snell [MVP]

Alternatively, here's a shorter code:

Private Sub Structure_type_AfterUpdate()
Me![Bridge superstructure data subform].Visible =
(Me.Structure_type.Value=1)
Me![Culvert structure data subform].Visible = (Me.Structure_type.Value=2)
Me![Sign/Wall structure data subform].Visible = (Me.Structure_type.Value=3)
End Sub

--

Ken Snell
<MS ACCESS MVP>

Ken Snell said:
I'm guessing at which subforms are to be visible for each value of the
option group, but this should give you one idea of how to structure the
code.

Private Sub Structure_type_AfterUpdate()
Select Case Me.Structure_type.Value
Case 1
Me![Bridge superstructure data subform].Visible = True
Me![Culvert structure data subform].Visible = False
Me![Sign/Wall structure data subform].Visible = False
Case 2
Me![Bridge superstructure data subform].Visible = False
Me![Culvert structure data subform].Visible = True
Me![Sign/Wall structure data subform].Visible = False
Case 3
Me![Bridge superstructure data subform].Visible = False
Me![Culvert structure data subform].Visible = False
Me![Sign/Wall structure data subform].Visible = True
End Select
End Sub
--

Ken Snell
<MS ACCESS MVP>




Hermie71 said:
I've tried this coding which gets me part way there but ... can you give
me a
code example of what you mean? I had tried the AfterUpdate command
previously. Much thanks!!

Private Sub Structure_type_Click()

Me!Structure_type = 1
Me![Bridge superstructure data subform].Visible = _
Not Me![Culvert structure data subform].Visible
Me!Structure_type = 2
Me![Culvert structure data subform].Visible = _
Not Me![Bridge superstructure data subform].Visible
Me!Structure_type = 3
Me![Sign/Wall structure data subform].Visible = _
Not Me![Sign/Wall structure data subform].Visible

End Sub

Ken Snell said:
Use the AfterUpdate event of the option group to make the subform
controls
visible/invisible, depending on the value of the option group.

--

Ken Snell
<MS ACCESS MVP>

I have an option control group with three selections; 1, 2 and 3. I
also
have three subforms stacked at the same location on a main form.

I wish to have my selection in the option control group control the
hiding
or displaying of subforms. That is, when I select option 1, subform 1
will
be visible and subforms 2 and 3 will be hidden. When option 2 is
selected,
subform 2 will be visible and subforms 1 and 3 will be hidden. When
option 3
is selected, subform 3 will be visible and subforms 1 and 2 will be
hidden.

I am also assuming that since 1 is my default selection that on
subform 1
the properties for visible should be 'yes' and for subforms 2 and 3
the
property should be no.

I have read MS Article Q210600 " How to Use a Button to Hide and
Display a
Subform in Access" and understand it but can't convey the logic to an
option
control group. Help is greatly appreciated!
 
G

Guest

Thanks! This works great and the form visibility is controlled by the option
group. There are two things I notice though. One, on opening the mainform
all three of the subform labels are visible instead of the one whose option
group is selected. Second, as I scroll through the main forms' records, the
option group selection changes but the subform tied to it does not change
unless I manually click another option and then re-click the wanted option
group selection. Any ideas?

Ken Snell said:
Alternatively, here's a shorter code:

Private Sub Structure_type_AfterUpdate()
Me![Bridge superstructure data subform].Visible =
(Me.Structure_type.Value=1)
Me![Culvert structure data subform].Visible = (Me.Structure_type.Value=2)
Me![Sign/Wall structure data subform].Visible = (Me.Structure_type.Value=3)
End Sub

--

Ken Snell
<MS ACCESS MVP>

Ken Snell said:
I'm guessing at which subforms are to be visible for each value of the
option group, but this should give you one idea of how to structure the
code.

Private Sub Structure_type_AfterUpdate()
Select Case Me.Structure_type.Value
Case 1
Me![Bridge superstructure data subform].Visible = True
Me![Culvert structure data subform].Visible = False
Me![Sign/Wall structure data subform].Visible = False
Case 2
Me![Bridge superstructure data subform].Visible = False
Me![Culvert structure data subform].Visible = True
Me![Sign/Wall structure data subform].Visible = False
Case 3
Me![Bridge superstructure data subform].Visible = False
Me![Culvert structure data subform].Visible = False
Me![Sign/Wall structure data subform].Visible = True
End Select
End Sub
--

Ken Snell
<MS ACCESS MVP>




Hermie71 said:
I've tried this coding which gets me part way there but ... can you give
me a
code example of what you mean? I had tried the AfterUpdate command
previously. Much thanks!!

Private Sub Structure_type_Click()

Me!Structure_type = 1
Me![Bridge superstructure data subform].Visible = _
Not Me![Culvert structure data subform].Visible
Me!Structure_type = 2
Me![Culvert structure data subform].Visible = _
Not Me![Bridge superstructure data subform].Visible
Me!Structure_type = 3
Me![Sign/Wall structure data subform].Visible = _
Not Me![Sign/Wall structure data subform].Visible

End Sub

:

Use the AfterUpdate event of the option group to make the subform
controls
visible/invisible, depending on the value of the option group.

--

Ken Snell
<MS ACCESS MVP>

I have an option control group with three selections; 1, 2 and 3. I
also
have three subforms stacked at the same location on a main form.

I wish to have my selection in the option control group control the
hiding
or displaying of subforms. That is, when I select option 1, subform 1
will
be visible and subforms 2 and 3 will be hidden. When option 2 is
selected,
subform 2 will be visible and subforms 1 and 3 will be hidden. When
option 3
is selected, subform 3 will be visible and subforms 1 and 2 will be
hidden.

I am also assuming that since 1 is my default selection that on
subform 1
the properties for visible should be 'yes' and for subforms 2 and 3
the
property should be no.

I have read MS Article Q210600 " How to Use a Button to Hide and
Display a
Subform in Access" and understand it but can't convey the logic to an
option
control group. Help is greatly appreciated!
 
K

Ken Snell [MVP]

You can use the same change to handle the opening of the form and the
scrolling through the main form's records. Just put the same code steps in
the event procedure for the main form's Current event.

The current event occurs whenever you change from one record to another, and
it also occurs when the form opens and the first record is made active in
the form.
--

Ken Snell
<MS ACCESS MVP>



Hermie71 said:
Thanks! This works great and the form visibility is controlled by the
option
group. There are two things I notice though. One, on opening the
mainform
all three of the subform labels are visible instead of the one whose
option
group is selected. Second, as I scroll through the main forms' records,
the
option group selection changes but the subform tied to it does not change
unless I manually click another option and then re-click the wanted option
group selection. Any ideas?

Ken Snell said:
Alternatively, here's a shorter code:

Private Sub Structure_type_AfterUpdate()
Me![Bridge superstructure data subform].Visible =
(Me.Structure_type.Value=1)
Me![Culvert structure data subform].Visible = (Me.Structure_type.Value=2)
Me![Sign/Wall structure data subform].Visible =
(Me.Structure_type.Value=3)
End Sub

--

Ken Snell
<MS ACCESS MVP>

Ken Snell said:
I'm guessing at which subforms are to be visible for each value of the
option group, but this should give you one idea of how to structure the
code.

Private Sub Structure_type_AfterUpdate()
Select Case Me.Structure_type.Value
Case 1
Me![Bridge superstructure data subform].Visible = True
Me![Culvert structure data subform].Visible = False
Me![Sign/Wall structure data subform].Visible = False
Case 2
Me![Bridge superstructure data subform].Visible = False
Me![Culvert structure data subform].Visible = True
Me![Sign/Wall structure data subform].Visible = False
Case 3
Me![Bridge superstructure data subform].Visible = False
Me![Culvert structure data subform].Visible = False
Me![Sign/Wall structure data subform].Visible = True
End Select
End Sub
--

Ken Snell
<MS ACCESS MVP>




I've tried this coding which gets me part way there but ... can you
give
me a
code example of what you mean? I had tried the AfterUpdate command
previously. Much thanks!!

Private Sub Structure_type_Click()

Me!Structure_type = 1
Me![Bridge superstructure data subform].Visible = _
Not Me![Culvert structure data subform].Visible
Me!Structure_type = 2
Me![Culvert structure data subform].Visible = _
Not Me![Bridge superstructure data subform].Visible
Me!Structure_type = 3
Me![Sign/Wall structure data subform].Visible = _
Not Me![Sign/Wall structure data subform].Visible

End Sub

:

Use the AfterUpdate event of the option group to make the subform
controls
visible/invisible, depending on the value of the option group.

--

Ken Snell
<MS ACCESS MVP>

I have an option control group with three selections; 1, 2 and 3. I
also
have three subforms stacked at the same location on a main form.

I wish to have my selection in the option control group control the
hiding
or displaying of subforms. That is, when I select option 1,
subform 1
will
be visible and subforms 2 and 3 will be hidden. When option 2 is
selected,
subform 2 will be visible and subforms 1 and 3 will be hidden.
When
option 3
is selected, subform 3 will be visible and subforms 1 and 2 will be
hidden.

I am also assuming that since 1 is my default selection that on
subform 1
the properties for visible should be 'yes' and for subforms 2 and 3
the
property should be no.

I have read MS Article Q210600 " How to Use a Button to Hide and
Display a
Subform in Access" and understand it but can't convey the logic to
an
option
control group. Help is greatly appreciated!
 
G

Guest

I'm obviously no programmer. With your help, the programming portion of my
database is nearly complete. Thanks for the help!

Ken Snell said:
You can use the same change to handle the opening of the form and the
scrolling through the main form's records. Just put the same code steps in
the event procedure for the main form's Current event.

The current event occurs whenever you change from one record to another, and
it also occurs when the form opens and the first record is made active in
the form.
--

Ken Snell
<MS ACCESS MVP>



Hermie71 said:
Thanks! This works great and the form visibility is controlled by the
option
group. There are two things I notice though. One, on opening the
mainform
all three of the subform labels are visible instead of the one whose
option
group is selected. Second, as I scroll through the main forms' records,
the
option group selection changes but the subform tied to it does not change
unless I manually click another option and then re-click the wanted option
group selection. Any ideas?

Ken Snell said:
Alternatively, here's a shorter code:

Private Sub Structure_type_AfterUpdate()
Me![Bridge superstructure data subform].Visible =
(Me.Structure_type.Value=1)
Me![Culvert structure data subform].Visible = (Me.Structure_type.Value=2)
Me![Sign/Wall structure data subform].Visible =
(Me.Structure_type.Value=3)
End Sub

--

Ken Snell
<MS ACCESS MVP>

I'm guessing at which subforms are to be visible for each value of the
option group, but this should give you one idea of how to structure the
code.

Private Sub Structure_type_AfterUpdate()
Select Case Me.Structure_type.Value
Case 1
Me![Bridge superstructure data subform].Visible = True
Me![Culvert structure data subform].Visible = False
Me![Sign/Wall structure data subform].Visible = False
Case 2
Me![Bridge superstructure data subform].Visible = False
Me![Culvert structure data subform].Visible = True
Me![Sign/Wall structure data subform].Visible = False
Case 3
Me![Bridge superstructure data subform].Visible = False
Me![Culvert structure data subform].Visible = False
Me![Sign/Wall structure data subform].Visible = True
End Select
End Sub
--

Ken Snell
<MS ACCESS MVP>




I've tried this coding which gets me part way there but ... can you
give
me a
code example of what you mean? I had tried the AfterUpdate command
previously. Much thanks!!

Private Sub Structure_type_Click()

Me!Structure_type = 1
Me![Bridge superstructure data subform].Visible = _
Not Me![Culvert structure data subform].Visible
Me!Structure_type = 2
Me![Culvert structure data subform].Visible = _
Not Me![Bridge superstructure data subform].Visible
Me!Structure_type = 3
Me![Sign/Wall structure data subform].Visible = _
Not Me![Sign/Wall structure data subform].Visible

End Sub

:

Use the AfterUpdate event of the option group to make the subform
controls
visible/invisible, depending on the value of the option group.

--

Ken Snell
<MS ACCESS MVP>

I have an option control group with three selections; 1, 2 and 3. I
also
have three subforms stacked at the same location on a main form.

I wish to have my selection in the option control group control the
hiding
or displaying of subforms. That is, when I select option 1,
subform 1
will
be visible and subforms 2 and 3 will be hidden. When option 2 is
selected,
subform 2 will be visible and subforms 1 and 3 will be hidden.
When
option 3
is selected, subform 3 will be visible and subforms 1 and 2 will be
hidden.

I am also assuming that since 1 is my default selection that on
subform 1
the properties for visible should be 'yes' and for subforms 2 and 3
the
property should be no.

I have read MS Article Q210600 " How to Use a Button to Hide and
Display a
Subform in Access" and understand it but can't convey the logic to
an
option
control group. Help is greatly appreciated!
 
K

Ken Snell [MVP]

You're welcome.

--

Ken Snell
<MS ACCESS MVP>

Hermie71 said:
I'm obviously no programmer. With your help, the programming portion of
my
database is nearly complete. Thanks for the help!

Ken Snell said:
You can use the same change to handle the opening of the form and the
scrolling through the main form's records. Just put the same code steps
in
the event procedure for the main form's Current event.

The current event occurs whenever you change from one record to another,
and
it also occurs when the form opens and the first record is made active in
the form.
--

Ken Snell
<MS ACCESS MVP>



Hermie71 said:
Thanks! This works great and the form visibility is controlled by the
option
group. There are two things I notice though. One, on opening the
mainform
all three of the subform labels are visible instead of the one whose
option
group is selected. Second, as I scroll through the main forms'
records,
the
option group selection changes but the subform tied to it does not
change
unless I manually click another option and then re-click the wanted
option
group selection. Any ideas?

:

Alternatively, here's a shorter code:

Private Sub Structure_type_AfterUpdate()
Me![Bridge superstructure data subform].Visible =
(Me.Structure_type.Value=1)
Me![Culvert structure data subform].Visible =
(Me.Structure_type.Value=2)
Me![Sign/Wall structure data subform].Visible =
(Me.Structure_type.Value=3)
End Sub

--

Ken Snell
<MS ACCESS MVP>

I'm guessing at which subforms are to be visible for each value of
the
option group, but this should give you one idea of how to structure
the
code.

Private Sub Structure_type_AfterUpdate()
Select Case Me.Structure_type.Value
Case 1
Me![Bridge superstructure data subform].Visible = True
Me![Culvert structure data subform].Visible = False
Me![Sign/Wall structure data subform].Visible = False
Case 2
Me![Bridge superstructure data subform].Visible = False
Me![Culvert structure data subform].Visible = True
Me![Sign/Wall structure data subform].Visible = False
Case 3
Me![Bridge superstructure data subform].Visible = False
Me![Culvert structure data subform].Visible = False
Me![Sign/Wall structure data subform].Visible = True
End Select
End Sub
--

Ken Snell
<MS ACCESS MVP>




I've tried this coding which gets me part way there but ... can you
give
me a
code example of what you mean? I had tried the AfterUpdate command
previously. Much thanks!!

Private Sub Structure_type_Click()

Me!Structure_type = 1
Me![Bridge superstructure data subform].Visible = _
Not Me![Culvert structure data subform].Visible
Me!Structure_type = 2
Me![Culvert structure data subform].Visible = _
Not Me![Bridge superstructure data subform].Visible
Me!Structure_type = 3
Me![Sign/Wall structure data subform].Visible = _
Not Me![Sign/Wall structure data subform].Visible

End Sub

:

Use the AfterUpdate event of the option group to make the subform
controls
visible/invisible, depending on the value of the option group.

--

Ken Snell
<MS ACCESS MVP>

I have an option control group with three selections; 1, 2 and 3.
I
also
have three subforms stacked at the same location on a main form.

I wish to have my selection in the option control group control
the
hiding
or displaying of subforms. That is, when I select option 1,
subform 1
will
be visible and subforms 2 and 3 will be hidden. When option 2
is
selected,
subform 2 will be visible and subforms 1 and 3 will be hidden.
When
option 3
is selected, subform 3 will be visible and subforms 1 and 2 will
be
hidden.

I am also assuming that since 1 is my default selection that on
subform 1
the properties for visible should be 'yes' and for subforms 2
and 3
the
property should be no.

I have read MS Article Q210600 " How to Use a Button to Hide and
Display a
Subform in Access" and understand it but can't convey the logic
to
an
option
control group. Help is greatly appreciated!
 

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