How to show related values in i subform.

Klingest

Registered User.
Local time
Today, 02:32
Joined
Aug 11, 2017
Messages
11
Hello people

I have a form with two subforms within it.

The first subform displays a table named "tblCalculation", the second subform displays table named "tblSubCalculation".

The two tables are related in a one to many relationship as follows:

"tblCalculation" [ one -> many ] "tblSubCalculation"

What I want to do is, that when you select a record in the subform showing "tblCalculation", the related values from "tblSubCalculation" shall be displayed in the other subform.

How can I do that?
 
Depends on how you have the form & 2 subforms setup.
You haven't mentioned the main form - what is its datasource ... or is it just a container for the 2 subforms.

Is there a parent child relationship set up between the form & each subform
OR is there a parent child relationship set up between the 2 subforms

Whichever of the above is true, which fields link the two forms?
 
Add an Unbound Textbox to Main form.
say (txtSub1PK).
on the second subform, goto Property->Data
Link Master Fields: txtSub1PK
Link Child Fields: <Foreign Key of subform2>


On Current Event of Subform1, set the value of unbound textbox to its Primary Key:


Private Sub Form_Current()
Me.Parent!txtSub1PK = Me.<PK key>
End Sub




***
this will show related records of subform1 in subform2.
 

Users who are viewing this thread

Back
Top Bottom