views:

592

answers:

1

I'm trying to build a database for a hospital program. I have two tables that are related in a parent-child relationship. I have a form to add new records (records that dont already have a parent record) and I want to build forms that allow me to view all of a parent record's "children" as well as allowing me to edit them. I want this form to allow me to search for a record in such a way that only one parent record can be returned.

Please see my database at http://rapidshare.com/files/283207434/IC.mdb.html

-check the form called "TEST". I can't get it to work so that the main form controls can act as filters to display the child records in the subform. I have been to many many forums and my lack of knowledge makes forum tag almost useless. A friend told me that this service was fast! If there is someone out there willing to help this poor soul over IM or something, that would be terrific! But I'm willing to work with you here too :) Hope to hear from you soon!!!

-Thanks Zorkmid

A: 

There isn't really any code involved. From what other forums have told me, I don't need any code. Here's what a MS MVP said. I've tried all that, and I cant pinpoint the errior.

Build you main form based on the main (parent) table. DO NOT use a sql join

to bring in child records. Simply build a form on this main table.

To have the form "jump" for move to selected name simply use the combo box wizard and drop in a combo box (follow the instructions).

Now, create a continues form based on the child table. Again, you can build this form and base it on the child table. Again, don't use a sql join, nor try to bring in any fields or parts of the parent table.

It is assumed you also correctly setup the relationship between the two tables in the relationship window.

Now, bring up your "main" form (the one based on the parent table) in design mode. Make sure wizard are enabled, and then drop in a sub-form control and follow the wizard instructions (choose the correct form based on the child table). Ms-access will setup this for you.

The end result is that if you navigate in the main form, the child form (sub form) will follow and display the correct child records. and, in place of using the navigation, if you use the combo box created by the wizard, then again when the parent form move to a record, the child form will display the correct records.

All of the above can be done without you having to write one line of code.

Have you got correctly specified foreign key constraints on the tables?The thing with having no code is that it's impossible to ask, answer and discuss a specific coding issue. Is your wizard generating code behind the scenes perhaps?
Joe
The properties in the form that make this work are the LinkChildFields and LinkMasterFields properties of the Subform frame. The subform frame is the frame that contains your subform, NOT the subform itself. See http://msdn.microsoft.com/en-us/library/aa196316(office.11).aspx
Robert Harvey
If the subform is not tracking the record you have selected in the main form, it is usually because one of these two properties is not set properly, although there can be other causes.
Robert Harvey