Setting recordsource and master/child link on subform that is used many times

  • Thread starter Thread starter Raj Patel
  • Start date Start date
R

Raj Patel

Hello,

I am trying to build a medical research database app. I have many
problems, but I hope I can work through them with your help.

I have a subform that I used over and over. It has three fields
(Reason, Code, and SP). This subform maps to a table called
tblDiagnoses which is organized as follows -

tblDiagnoses
------------
DiagnosisID
Reason
Code
SP

The tblDiagnoses is part of several many-to-many relationships. Since
I use the same subform repeatedly I set the recordsource when the form
is opened. This way I can set the recordsource to exactly what the the
subform should display. However, since I set the recordsource through
VBA I cannot use the Master/Child Link properties on the subform. I
have to set the recordsource to a static query. What is the accetped
way of setting the recordsource for a subform that is used repeatedly
and that needs to set the Master/Child Link property. I need to set
this because so that he linking table in the appropriate many-to-mant
relationship to tblDiagnoses gets filled in.

Thanks guys!
 
Presumably you are setting the RecordSource of each subform from code in the
main form. After doing that, you may be able to set the LinkMasterFields and
LinkChildFields in your code as well.

Alternatively, you may be able to get the desired records just be adding
(hidden) text boxes on the main form, and naming them in the
LinkMasterFields at design time.
 
Back
Top