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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
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,545
Messages
6,120,128
Members
448,947
Latest member
test111

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