Synchronizing subforms

H

Hydra

I have tables A, B, and C, each one to many, so my key fields look like
A
1
2

B
1,1
1,2

C
1,1,1
1,1,2
1,1,3
1,2,1
1,2,2
1,2,3

So the primary key for B is two fields and the primary Key for C is three
fields.

I have a form on A with B and C as subforms.

Id like form c to show only thos records which apply to the record selected
on form 2.

So If 1.1 is selected on form 2 then ony records beginning with 1.1 appear
on form three.. I had this working but I broke it and now can't figure out
what I did before!
 
J

June7 via AccessMonster.com

Check the master/child links properties for the subform container controls.
What is in there?
 
H

Hydra

Well, form B works because it depends onthe master form, so th emaster child
link works.

But form C depends on what record is selected in form B. My problem is that
it shows all the records associated with the record selected on form A
regardless of what is selected on form b.

Therefore there is some code in the OnCurrent method of the form but I can't
figure out how it is supposed to work:

Sub Form_Current()

Dim ParentDocName As String

On Error Resume Next
ParentDocName = Me.Parent.Name
MsgBox (Me.Parent.Name)

If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err
Me.Parent![SA Subform].Requery
End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Error$
Resume Form_Current_Exit

End Sub
 
H

Hydra

I finally got it. the code makes the form requery. The data souce for the
form thris of the form:


Select [Fields] From [Table3]
Where [Keyfield 2] = [Forms]![Form 1]![Subform 2].[Form]![keyfield 2]
 

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