-----Original Message-----
My configuration is as follows:
I have three subform controls on a page of a tab control.
SubformA is a continuous form tied to table Profiles.
SubformB is a continuous form tied to table Progress.
SubformC is a continuous form tied to table [Progress
Level 2]. The is a one to many relationship between the
Profiles tables and the Progress table. There is a one to
many relationship between the Profiles table and the
[Progress Level 2] table. The field which links the
tables is StudentID. It is the primary key in Profiles
and just a field in the other two tables. When I select a
record in SubformA (via record selector), I want SubformB
and SubformC to display the records for this student
(StudentID).
At present my techniquye is to set the recordsource for
SubformB and SubformC in the OnCurrent event in SubformA.
It works but . . . if there are no existing records in
SubformC, then I cannot create records there. I did some
acrobatics to make that work. But it all seems dorky. As
I said, I tried your suggestions and still no workie.
My guess is that your problem creating records in SubformC comes from
the absence of Link Master/Child Fields to fill in the necessary key
values as a record is inserted. There are ways to work around that if
you really want to continue with this approach, but I think setting up
the Link Master/Child Fields properly according to the method Graham,
Marsh, and I have been suggesting is by far the best way. So let's try
to get that to work.
I'm going to assume for the moment that the tables [Progress] and
[Progress Level 2] are both related to table [Profiles] (via StudentID),
but not to each other. Try these steps, which I'll make as detailed as
I can:
1. On SubformA, you must have a control that is bound to the StudentID
field. Name that control "txtStudentID". (Note -- the control *could*
just be named "StudentID", but I'm telling you to give it a distinct
name so that in a later step I can ensure that you are referring to the
control, not the field.)
2. On the *main* form, add a text box. Name this text box
"txtCurrentStudent".
3. On the main form, set the ControlSource property of txtCurrentStudent
to this expression:
=[SubformA].[Form]![txtStudentID]
4. On the main form, open the property sheet of the subform control that
displays SubformB. Its name *may* be "SubformB", or it may be something
else; it doesn't matter, but make sure it's the property sheet of the
subform control you're looking at, not the form inside that control.
5. On the Data tab of the property sheet, set properties as shown:
Link Child Fields: StudentID
Link Master Fields: txtCurrentStudent
Then close the property sheet.
6. On the main form, open the property sheet of the subform control that
displays SubformC. Its name *may* be "SubformC", or it may be something
else; it doesn't matter, but make sure it's the property sheet of the
subform control you're looking at, not the form inside that control.
7. On the Data tab of the property sheet, set properties as shown:
Link Child Fields: StudentID
Link Master Fields: txtCurrentStudent
Then close the property sheet.
8. "Comment out" or remove any code you have in the main form or
SubformA that sets the RecordSource properties of the other subforms.
These subforms should just have their RecordSource properties set at
design time to draw all records from their respective tables.
9. Save the form (and subforms, if necessary).
10. Open the main form and try it out.
That ought to work, Doug. If it doesn't, something's going on that we
don't know about.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
.