Synchronize two subforms

J

JNew

Greetings,

I am trying to create a structure that avoids nesting
subforms. In other words, the main form will display two
separate subforms, but subform(2) is the "many" side of a
relationship with subform(1). I'm having trouble getting
subform(2) to update/synchronize when I move through the
records in subform(1).

Main form:
Name = "CourseSecMain"
Primary key = "CourseID"
Subform(1) control name = "Sections"
Subform(2) control name = "Students"

Subform(1):
Form name = "CourseSecSub"
Primary key = "SectionID"
Links to main form using "CourseID"

Subform(2):
Form name = "CourseSecStudentsSub"
Composite PK = "SectionID" & "StudentID"
Link Master Field = "Forms![CourseSecMain]![Sections].Form!
[SectionID]

I have successfully created the subforms, and when I move
through records on the main form, subform(2) does update
itself to display the students in the FIRST section
displayed. It won't update itself when I click on a
different section.

In subform(1)'s OnCurrent event, I have added this code:
"Forms![CourseSecMain]![Students].Form.Requery" but it
doesn't do the trick.

Any guidance will certainly be appreciated.

jn
 
P

PC Datasheet

Add a textbox to the main form and name it LinkField. Put the following code in
subform1's OnCurrent event:
Me.Parent!LinkField = Me!NameOfTextboxHoldingSubform1PK

In subform2, set the LinkMaster property to LinkField and the LinkChild property
to the corresponding foreign key.
 
A

Annelie

I was hoping that I could utilize your suggestion.
My MainForm is the Employee List
linked to subform1 by Employee Name, where I enter hours worked by day by
job
subform2 hold information about the job and I would like to link the 2
subforms through the job no.

I created the textbox on the employee list and entered the items to
subform1's current event.
That works, the job number now shows up in that text box.
But when I try to link subform2 to the textbox, the textbox does not appear
as an available link field.
Help,
Annelie

PC Datasheet said:
Add a textbox to the main form and name it LinkField. Put the following code in
subform1's OnCurrent event:
Me.Parent!LinkField = Me!NameOfTextboxHoldingSubform1PK

In subform2, set the LinkMaster property to LinkField and the LinkChild property
to the corresponding foreign key.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com







JNew said:
Greetings,

I am trying to create a structure that avoids nesting
subforms. In other words, the main form will display two
separate subforms, but subform(2) is the "many" side of a
relationship with subform(1). I'm having trouble getting
subform(2) to update/synchronize when I move through the
records in subform(1).

Main form:
Name = "CourseSecMain"
Primary key = "CourseID"
Subform(1) control name = "Sections"
Subform(2) control name = "Students"

Subform(1):
Form name = "CourseSecSub"
Primary key = "SectionID"
Links to main form using "CourseID"

Subform(2):
Form name = "CourseSecStudentsSub"
Composite PK = "SectionID" & "StudentID"
Link Master Field = "Forms![CourseSecMain]![Sections].Form!
[SectionID]

I have successfully created the subforms, and when I move
through records on the main form, subform(2) does update
itself to display the students in the FIRST section
displayed. It won't update itself when I click on a
different section.

In subform(1)'s OnCurrent event, I have added this code:
"Forms![CourseSecMain]![Students].Form.Requery" but it
doesn't do the trick.

Any guidance will certainly be appreciated.

jn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top