Solved

Joining forms to Sub forms (Using invisible)

Posted on 2011-03-21
2
157 Views
Last Modified: 2012-05-11
Hi,

Often, when I join a form to a sub form I find I need to put invisible fields on the form to facilitate the join.  I am wondering is this the best way to do things??

EXAMPLE:
A Teacher has many students.

When I am calling a subform to display all the student names  (for one particular teacher) I find that I need to put the "TEACHERID" onto the main form and make this (numeric) field invisible.

I am happy to continue doing this but wonder if there is a less convoluted way.

(My example is not very clear but hopefully you will get the meaning)
0
Comment
Question by:Patrick O'Dea
2 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 35180979
You can do it a variety of ways, but basically there are two methods.

1.  Use the Link Master/Link Child fields properties in the Data tab of the Properties window.  Used when you your main form is bound to a data source

2.  Write the RecordSource of the subform so that it refers to one or more fields in your main form.  You are probably already doing this.

Either way, you are going to have to have one or more fields on your main form which define which records to show in the subform.  How are you selecting the teacher whose students you want to display?  If it is a combo or list box, modify the RowSource for the control to include the TeacherID as the first column in the query, then set the controls Control Count =2, Bound Column = 1, and Column widths to something like 0"; 2".  This will allow you to have the TeacherID in the form.

Then, if you are using option #1, the subform will probably refresh automatically.  If you are using option #2, you will have to use the AfterUpdate or Click event of the combo/list to requery the subform.

0
 

Author Closing Comment

by:Patrick O'Dea
ID: 35181060
Thanks fyed,

Very comprehensive answer.

As I suspected, I am doing things a slightly convoluted way.  I will study you answer in full detail later.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

914 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now