PS: You may need to use the above syntax to set the prior source object to spaces before assigning a new source object.
Main Topics
Browse All TopicsI have a main form called Employees
I have tabs on this main form Employee and on on of the pages called pgLife I have a subform called Life_Events
I would like when the form is open that macro run that runs a code (runcode) that runs a function that will change the sourceobject from Life_Events to Daily_Events
The Link Master Fields and Link Child Fileds are Employee ID
Right now when the form open I get a Halt error and the subform is still showing the original form. I know I can just replace the source object and save the form but for other reason I need to have the subform switched out through code.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Is Employee the name of your main form?
Is Life_Events the name of the subform control on the main form?
Are you executing the code from the main form?
try it this way: Forms!Employee!Life_Events
^^^^^
If your code is executing from the subform source object and not from the main form, the syntax would probably be as follows: Me.SourceObject= "Daily_Events"
The Employee is the main form
Life_Events is the name of the subform
current source object prior to the code running is Life_Events
want to switch the source object to Daily_Events
Want to run it by calling a function so Me. does not work. I wish I could change the Emplyee form then this would be a piece of cake but the form does not allow a design change from the origanl in that you have to call function to make the change using macros etc.
Not sure if the tab the subform on makes a difference pgEmployee
here is all the ones I tried
Business Accounts
Answer for Membership
by: puppydogbuddyPosted on 2009-11-02 at 10:33:05ID: 25722141
Your syntax would look like the following. Replace illustrative objects with your actual objects formContro l.SourceOb ject = "SourceObjectName"
Forms!YourMainform!YourSub