if then subform

P

Papa Jonah

I have a form with a set of radio buttons. I want the radio buttons (two
options) to define which of two subforms appear.
I suspect I need to select the option group and put something in for after
update, but I have no idea what.
Then I suspect I put both subforms on the form and set their visible setting
to no.
Some how after update of the radiobutton one subform or the other will have
the visible setting turned to yes.

Do I have the right idea? How do I implement it?

TIA

Papp
 
D

Damon Heron

Yes, use an option group with two buttons. The option group click event
(here called Frame1) can do everything you want.

Private Sub Frame1_Click()
If Frame1.value= 1 then
me!your1stsubformName.Form.Visible= true
me!your2ndsubformName.Form.Visible= false
else
me!your1stsubformName.Form.Visible= false
me!your2ndsubformName.Form.Visible= true
End if

End Sub

Damon
 
P

Papa Jonah

Damon,
That worked great. However, I know need the chosen subform to stay selected
within each record as I select the individual records. For example, record 1
may have selected subform 1 and records 2-5 have subform 2.

How can I do that.
 
D

Damon Heron

It sounds like something in the record is determining the choice of
subforms, rather than the user. That is a different matter.
What distinquishes each record? The main form's current event would be a
good place to set the subform based on some
criteria found on the current record. Look at the current event in help.
something like:
if "my control on mainform=somevalue" then make this subform visible, else
make the other subform visible.

Damon
 
P

Papa Jonah

Damon Heron said:
It sounds like something in the record is determining the choice of
subforms, rather than the user. That is a different matter.
What distinquishes each record? The main form's current event would be a
good place to set the subform based on some
criteria found on the current record. Look at the current event in help.
something like:
if "my control on mainform=somevalue" then make this subform visible, else
make the other subform visible.

Damon




The numeric value associated with the selected radiobutton gets stored in a field called reviewassessment. So when the user initially selects the button, the number gets stored in a table. I suspect, based on this number, the subform is chosen to be visible or not.
I can't figure out how to do that. In Access 2007 I don't see a current
record option.
TIA
 
D

Damon Heron

With your main form in design view, right click to select properties. On
the event tab, the first selection is On Current. click on the "..." which
will allow you to enter code that executes each time you move to a different
record. The ReviewAssessment number (from the table) should be on your main
form. The part I don't get is why you have a button to select the
reviewassessment number. But in any event, the on current event code to
select the subform to view should be somewhat like my previous examples:
If ReviewAssessment= 1 then 'or whatever value it has...
me!your1stsubformName.Form.Visible= true
me!your2ndsubformName.Form.Visible= false
else
me!your1stsubformName.Form.Visible= false
me!your2ndsubformName.Form.Visible= true
End if

Damon
 
P

Papa Jonah

Thanks Damon.
The part I was missing was the oncurrent for the form rather than the radio
button frame.
The button is just the radio button on the main form so that through the
user's selection of the radio button, the appropriate subform shows up.

Thanks again.
Papa
 
Top