[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2014-08-14
Medium Priority
Last Modified: 2014-08-14
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.
Question by:Lou Dufresne
LVL 58

Accepted Solution

Jim Dettman (Microsoft MVP/ EE MVE) earned 2000 total points
ID: 40261877
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.


Author Closing Comment

by:Lou Dufresne
ID: 40262149
Thanks Jim. This is a big help to me


Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question