Subform Change with Click of Radio Button

  • Thread starter Mable Y. via AccessMonster.com
  • Start date
M

Mable Y. via AccessMonster.com

I have a form with radio buttons on it and one subform at the bottom of the
form. I want to be able to click on the radio button and have the subform
source object change to populate with a new subform.

For example, if I click on MAResults radio button the subform populates with
the MAResults subform. Then if I click on the actionResults radio button the
subform populates with the ActionResults subform. I only want to use one
subform and have it change or load depending upon the radio button clicked.

Can someone help me with this?

Thanks,
Mable
 
T

tina

when you change a subform control's SourceObject where the main form's
underlying table has a parent/child relationship with the subform's
underlying table, you have to set the LinkChildFields and LinkMasterFields
properties, as well as the SourceObject property. you can do it by running a
Select Case statement from the option group control's Click event, as

Select Case Me!OptionGroupName
Case 1
Me!SubformControlName.SourceObject = "name of the subform
object"
Me!SubformControlName.LinkChildFields = "name of subform's
foreign key field"
Me!SubformControlName.LinkMasterFields = "name of main form's
primary key field"

note that the value of the option group = the OptionValue property of the
radio button that you clicked.

hth
 
M

Mable Y. via AccessMonster.com

Ok . My subform is sfrmContact . The radio button name is "Contacts" the
value is "1". I entered the following

Select Case Me.Contacts
Case 1
Me!sfrmContact.SourceObject = "sfrmContact"
Me!sfrmContact.LinkChildFields = idNo
Me!sfrmContact.LinkMasterFields = idNo
End Select


But it gives me the error that: You entered an expression that has no value.
and the debugger opens and highlights the Select Case.

What am I doing wrong??

Thanks,
Mable
when you change a subform control's SourceObject where the main form's
underlying table has a parent/child relationship with the subform's
underlying table, you have to set the LinkChildFields and LinkMasterFields
properties, as well as the SourceObject property. you can do it by running a
Select Case statement from the option group control's Click event, as

Select Case Me!OptionGroupName
Case 1
Me!SubformControlName.SourceObject = "name of the subform
object"
Me!SubformControlName.LinkChildFields = "name of subform's
foreign key field"
Me!SubformControlName.LinkMasterFields = "name of main form's
primary key field"

note that the value of the option group = the OptionValue property of the
radio button that you clicked.

hth
I have a form with radio buttons on it and one subform at the bottom of the
form. I want to be able to click on the radio button and have the subform
[quoted text clipped - 9 lines]
Thanks,
Mable
 
T

tina

your code errs out because radio buttons have no value. look at my code
sample again. the Select Case statement draws the value from the *option
group*, not a particular radio button in the group. as i said, "note that
the value of the option group = the OptionValue property of the radio button
that you clicked."

you have more than one radio button in the option group, correct? if you
click on each button *in form design view* and look at the OptionValue
property in the Properties box, you'll see that the value is different for
each radio button. so the Select Case statement has to look at the option
group value to determine which radio button you clicked. the Select Case
code should contain a Case statement for each available value, as

Select Case Me!OptionGroupName
Case 1
' the code to set a specific source object and its' linking
properties.
Case 2
' the code to set another specific source object and its'
linking properties.
End Select

take a look at the Select Case topic in VBA Help to get a better
understanding of the statement syntax and how it works.

hth


Mable Y. via AccessMonster.com said:
Ok . My subform is sfrmContact . The radio button name is "Contacts" the
value is "1". I entered the following

Select Case Me.Contacts
Case 1
Me!sfrmContact.SourceObject = "sfrmContact"
Me!sfrmContact.LinkChildFields = idNo
Me!sfrmContact.LinkMasterFields = idNo
End Select


But it gives me the error that: You entered an expression that has no value.
and the debugger opens and highlights the Select Case.

What am I doing wrong??

Thanks,
Mable
when you change a subform control's SourceObject where the main form's
underlying table has a parent/child relationship with the subform's
underlying table, you have to set the LinkChildFields and LinkMasterFields
properties, as well as the SourceObject property. you can do it by running a
Select Case statement from the option group control's Click event, as

Select Case Me!OptionGroupName
Case 1
Me!SubformControlName.SourceObject = "name of the subform
object"
Me!SubformControlName.LinkChildFields = "name of subform's
foreign key field"
Me!SubformControlName.LinkMasterFields = "name of main form's
primary key field"

note that the value of the option group = the OptionValue property of the
radio button that you clicked.

hth
I have a form with radio buttons on it and one subform at the bottom of the
form. I want to be able to click on the radio button and have the
subform
[quoted text clipped - 9 lines]
Thanks,
Mable
 

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