Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Joining forms to Sub forms (Using invisible)

Posted on 2011-03-21
2
Medium Priority
?
165 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 49

Accepted Solution

by:
Dale Fye earned 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

916 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