Changing a subforms record source

caffeine_demon

Board Regular
Joined
Apr 19, 2007
Messages
64
Hi,

I have a form "Parks1" with a subform "childform", and I'd like to change the table that uses based on a set of option buttons. - so I've set macros to run on "gotfocus" for the option button.

Everything I saw suggested that:
Code:
Forms!parks1!childform.Form.RecordSource = "table1"
Forms!parks1!childform.Form.Requery

would do the trick - but it doesn't seem to make any difference - whatever I change the recordsource to, it has no effect on the subform, even if I set it to something nonsensical.

Any ideas what's going wrong?

Thanks!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Are you sure the event is triggered correctly? Normally you place option buttons within a frame, and use the after update event of the frame to do something with the choosen option value.
Try to place a msgbox line in the code, something like msgbox "Hello", to see if the event is triggered at all.
Further, if the option button is on the form 'parks1', you refer to the subform as: Me.NameOfTheSubform.Form.RecordSource = .
 
Upvote 0
yep - it's definitely triggering, as proved by an msgbox and stepping through,

even if I set it to recordsource="hairyballs" it doesn't even give an error!
 
Upvote 0
interesting, if I put MsgBox (childform.Form.RecordSource) before and after changing the recordsource, the value does change, but it doesn't reflect in the subform....
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,613
Members
449,090
Latest member
vivek chauhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top