Greetings,
Here is something I came up with that should do what you are asking:
Do the Link Master/Child thing with the mainform and subform1. Subform1
will need to be in Datasheet view for this trick to work.
The 2nd subform - which will also be placed on the mainform (and also
needs to be in datasheet view) will have its recordsource be based on a
query of the table for that subform (a query for table3). You will use
a parameter in the criteria field of the query for the link field
between table2 and table3. This parameter will be a function that you
will create in the Access Module tab. It is a very simple function.
Create and save a standard module (not a class module). Then create a
Public variable of the type whatever the link field type is between
table2 and table3. If the link field is a number then
Public fieldnameVar As Integer
If it is a text field then
Public fieldnameVar As String
Then function is just this:
Function Param() As Integer (or String)
Param = fieldnameVar
End Function
Save the module
Then in the query for table3 in the criteria for the linkfield just add
the function name
Param()
You need to include the Parentheses here.
In the first subform, go to its design view then go the code module for
that form. Every form code module has 2 dropdown boxes at the top of
the module. In the left dropdown for your subform - select "Form". In
the right dropdown select "Current". This is the Current Event of your
subform. Here is where you set the value of the globar var fieldNameVar
Private Sub Form_Current()
fieldnameVar = Me.yourLinkfield
End Sub
When you select a row in subform1, that triggers the Subform's current
Event. You can then set the value of fieldnameVar to the textfield in
the form. If you open the query that contains the Param() as criteria,
you will see that the query gets filtered by the value from the row you
selected in subform1.
Lastly, in the main form you will have a command button. In the command
button you will requery your 2nd subform and the correspponding rows
will show up.
Private Sub Command14_Click()
Me.Form3.Form.Requery
End Sub
So it is Me. the name of your 2nd subform and follow that by
..Form.Requery
You will now see that rows in the 2nd subform that are related to the
row you selected in the first subform.
Rich
*** Sent via Developersdex
http://www.developersdex.com ***