MS Access 2013 - Load a Query into the record source of the subform using VBA Code

I have a main and subform and wish to load a query into the subform record source using VBA but I don't know the syntax to do this.

The main form name is:  F-100-00 StartUpMain
The subform name is:  F-100-01 CFR_Pivot-All Records
The query name is: Q-100-01 CFR_Pivot-All records

I want to use VBA code to make the record source of the subform  (F-100-01 CFR_Pivot-All Records)
"Q-100-01 CFR_Pivot-All records" when the code is executed.

Question: Using the information listed above provide me with the correct syntax so that I can add this code statement to my VBA Sub process

Thanks for your assistance.
Ldufresne
LVL 1
Lou DufresneIT Business Analyst CSM / Project ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
If the code is in the main form:

 Me![<name of subform control>].Form.Recordsource = "Q-100-01 CFR_Pivot-All records"


"<name of subform control>" is the name of the control on the main form.   It may or may NOT be the same as the name of the subform as you see it in the database.   Click on the subform control, then look at the property sheet.   You want the name, not the sourceobject.

Jim.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lou DufresneIT Business Analyst CSM / Project ManagerAuthor Commented:
Thanks Jim. This is a big help to me

Ldufresne
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.