The TLDR version -
I want to pass master/child values (Study_ID) from one table to another through form/subform(s) operations and am having limited success. The values (Study_ID) are the primary key in my main table and linked to child tables (as Pt_ID), all in a one-to-many relationship setup with enforced referential integrity, cascade update, and delete. It's working for one of my subforms but not the other although it's set up the same. See last screenshot for error message.
The full version -
Hey all,
I'm building a database to collect specific medical info. Our team will be looking through records and gathering data like height, weight, blood pressure, medications taken, etc. Instead of collecting names (protected health information) we will use "Study_ID" in our main table and "Pt_ID" in our other child tables (labels are synonymous and I probably should have just kept them all as one or the other). Each value that could have multiple entries per patient (as Pt_ID) has it's own table - for example there's a blood pressure table with Pt_ID(s), dates and values, height and weight table with Pt_ID(s), dates and values, and medications table with Pt_ID(s), dates and values.
All info for the patient that will only have one value will be entered in the main form (named General Demographics). Things like gender and race will go here. Please see screenshot.
Once general info is entered users will select "Patient Encounters" which will open a new form. The Study ID value is passed from the General Demographics form to the Patient Encounter form, and set to a new record so values are blank/zero but inserted subform queries show past entries. This is where height, weight, blood pressure results, etc. will all be entered (inserted as subforms). Please see screenshot.
This form contains the subforms with queries tied to Study_ID/Pt_ID so it's easy to see/edit previous entries for whatever patient's records you are reviewing. Everything is mostly good to this point. It doesn't seem to automatically update the Pt_ID value from Study_ID as blood pressure, medications, etc are entered (even though they are linked fields and set to enforce referential integrity, cascade update, cascade delete in relationships and linked as Master/Child in the subform properties) so I created a macro to pass Study_ID to Pt_ID "After Update" of certain fields. For the blood pressure subform this seems to work just fine. See screenshots.
![]()
For the medications subform, though, I get an error message after I select a value from the drop-down for medications... even though it's set up identically to the blood pressure subform. I have an identical macro set up to pass Study_ID to Pt_ID after update of the "Medication" field. FYI, I also tried moving the macro to "On Click", "Before Update", and "On Change" properties of the field and got the same message. See screenshot.
After the error message is dismissed, Study_ID DOES get passed to Pt_ID but I can't seem to make it so I don't get the error message first. (FYI, Pt_ID's are in red because they will be set to visible = no in the user version of the database).
I tried to attach a couple more screenshots but evidently I'm limited to 5.
Thanks in advance for all the help!!!
Jon