Ryan W said:
Dirk,
Yes, I have tblDemographics linked to tblVisitID via MedicalRecord.
It is a one-many relationship.
Yes, the link master field of the subform is the PK of the main forms
recordsource. I thought I had to have txtmedicalrecord1 in order to
use AfterUpdate. (I am fairly new to this.)
They should never be different. As it stands now, on the main form if
I enter a medicalrecord I need to exit out of the form completely and
re-open the form in order for the medicalrecord to appear in the
subform. I am looking for a way to have it automatically appear.
Thank you for the response. Ryan
Based on what you tell me, here's how I think you should have it set up.
Your main form should be based on tblDemographics and your subform
should be based on tblVisitID -- not on a query joining the two tables.
I'm going to assume that the medical record number field in both tables
is called "MedicalRecord", but that may not be the case. In
tblDemographics, MedicalRecord is the primary key, while in tblVisitID i
t's a foreign key -- I'm guessing that th primary key of tblVisitID is a
field called VisitID.
Both the main form and the subform should have a control bound to the
MedicalRecord field of their respective recordsource tables. It doesn't
actually matter what these controls are called, but let's assume they
are both called txtMedicalRecord. On the main form, this control should
be visible (its Visible property should be set to Yes), but on the
subform the corresponding control should be invisible -- its Visible
property should be set to No, and you can set its width to 0 and move it
out of the way so you can lay out the other controls without having to
work around it or overlap it. You may or may not want the VisitID field
to be hidden likewise; if it's an autonumber field, you would do well
to hide it from your users.
The Link Master Fields property of the subform control on the main form
should be txtMedicalRecord (referring to the text box on the main form).
The Link Child Fields property should be set to MedicalRecord (referring
to the field in the subform's recordsource table). That ought to take
care of all the linking between the main form and the subform, including
inserting the main form's medical record number in the subform, without
your having to write a line of code.