• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1228
  • Last Modified:

Subform Recordsource

I use MS Access 2000.

I have an unbound main form and then bound subforms.

How do you programmatically change the Recordsource of a subform?

For Example:  When the user is doing data entry and the main form opens, the form (and subforms) auto populate with a new entry.  This part works great, but with this I am setting the subform's Recordsource the easy way - using the Properties GUI of the subform.  

I want to remove this property in the Properties GUI and set the subform's Recordsource in VB.

I'm thinking that either in the "On Open" or "On Current" Event I need to have code something like:

form.recordsource "qry1"

But that didn't work.


2 Solutions
You need to refer to the subform correctly first!!!

In access, you need to use:


to refer to the recordsource of the subform.

You will need to point the recordsource to a valid data source before you do this.

Please post more information if you need more help.
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
The correct syntax is:


What trips most people up is the NameOfSubFormCONTROL ... this is almost always NOT the name of the form contained within the subform, it's the name of the CONTROL on the main form.
BschreiberAuthor Commented:
Thanks, & sorry it took me so long to clean this up.  Project abandoned and I haven't been in E-E in a while.

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.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now