Solved Find records in a subform based on record selected in another subform (1 Viewer)

SurreyNick

Member
Local time
Today, 19:03
Joined
Feb 12, 2020
Messages
127
I have been trying to find the answer to this but without success. I want to populate a subform from the record I select in another subform.

I have attached a screen grab of the form to illustrate.

My parent form [MainForm] has two subforms [SubFrmA] and [SubFrmB]. The underlying data is provided by two queries [qryStudents] and [qryClasses] respectively. The subforms display different data but have StudentID (not visible) as a common field and I have set the Link Master and Link Child fields of SubFrmB to this field.

The text box on the parent form filters the records of SubFrmA based upon the text string typed into it. In the pic you can see I have 7 records which all share the string “gre”. As the records in SubFrmA change the content of SubFrmB also changes, displaying the classes attended for the current i.e. first record (in this instance 11X2 for Campbell) but if I click the record selector for one of the other six records in SubFrmA e.g. McGregor the result of SubFrmB remains unchanged i.e. it stays focused on record 1.

I am sure there is a straightforward bit of code which will do the trick but I can’t find it.

Can someone help?

Thanks.

Nick
 

Attachments

  • CurrentRecord.jpg
    CurrentRecord.jpg
    55.2 KB · Views: 96

CJ_London

Super Moderator
Staff member
Local time
Today, 19:03
Joined
Feb 19, 2013
Messages
16,601
there are several ways, but the easiest is probably to do the following

on your main form put a new textbox called say txtSF1PK. leave it visible for now, but once everything is working, you can hide it

in your subfrmA form current event put

parent.txtSF1PK=me.StudentID

in your subfrmB control, put txtSF1PK in the linkMaster property - the linkchild property should be studentID
 

SurreyNick

Member
Local time
Today, 19:03
Joined
Feb 12, 2020
Messages
127
Thanks. Works a treat :)
Nick
 

Users who are viewing this thread

Top Bottom