Solved

Subform Recordsource

Posted on 2004-08-25
4
1,167 Views
Last Modified: 2011-10-03
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.

Thanks.

-Bschreiber
0
Comment
Question by:Bschreiber
4 Comments
 
LVL 7

Assisted Solution

by:SQL_Stu
SQL_Stu earned 100 total points
ID: 11891950
You need to refer to the subform correctly first!!!

In access, you need to use:

MainForm!SubForm.Form.Recordsource

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.
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 50 total points
ID: 11892467
The correct syntax is:

MainForm.NameOfSubFormCONTROL.Form.Recordsource

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.
0
 

Author Comment

by:Bschreiber
ID: 12813670
Thanks, & sorry it took me so long to clean this up.  Project abandoned and I haven't been in E-E in a while.

-BSchreiber
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

808 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