Solved

Subform Recordsource

Posted on 2004-08-25
4
1,179 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

740 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