I looked at your code briefly and do not follow your logic. I can see if you enter a coil number and it is a new coil you would add that record to tblCoil (which is what we did before) but I'm not following how you are adding the additional info for the coil or the tables related to inspection (InspectMill and InspectionEvent) which underlie the form frmInspectMill .
The whole process starts at The Main Menu by clicking the "Inspections" button. When that button is clicked it opens frmInspectionEvent which is bound to tblInspectionEvent. The very first choice on that form is to choose a job number in the header. Job number is bound to tblJobs. There is a host of relevant data in tblJobs. And at this point there is a new record in tblInspectionEvent that has the date/time of the event, the job number ID, the operator's name, and the inspector's name.
Then clicking the "Mill Inspections" opens form frmInspectMill which instantiates a new record in tblInspectMill. The click event of that button sets the value of a global value to the newly created InspectionEvent_PK - and passes it through to frmInspectMill and subsequently to tblInspectMill where it is recorded in field InspectionEvent_FK.
That's how InspectionEvents, Jobs, and Mill Inspections are tied together.
The coils.............
Remembering that tblCoils is not and never will be an inventory-type table, there are many pieces of physical data that need to be recorded in tblCoils that wouldn't be included in our main coil inventory database anyway. Things like: "does the coil have a cardboard cylinder insert?" ; "does the coil have a peel coat applied?" ; etc. are not recorded anywhere in the inventory database but are absolutely critical pieces of data to collect to ascertain why we might be having issues with a particular coil or coils over time.
This data is best and most easily collected at the mill just during a mill inspection. In other words - the inspector knows nothing of which coil will be in the mill when he walks back to do an inspection. In other words, coil-related data relevant TO THE RUNNING OF THE MILL needs to be input at that stage not earlier when the coil is received. And as I have said before, we have partial coils that get used on several different jobs. Each of those jobs may have something unique about them that makes the event of the the coil being used more relevant than the coil itself.
Which means that data needs to be collected on frmInspectMill related to whatever coil number is associated with the material spooled on the mill - relevant to THAT inspection - not necessarily to the coil itself. Which is why the necessity of asking: "Are we looking at a coil that has never been entered or is this a partial that already exists in tblCoils."
Micron was concerned with adding data to "the many side" before adding it to "the one side" and that would be a concern if tblCoils was meant to be an inventory-style table but it isn't and never will be. We already have a robust system in place for that - but it is not linked to the inspection db at all - and never will be.
CoilNumber_PK is an autonumber so you don't have to insert it, Access will do that automatically.
I'll look more into your specific question re getting the value into the text box at " the bottom of the form ".
See if the attached db Coil Question 6 works for you when entering a made up coil number. The code for a new coil workds very well. Remember you have to start at the Main Menu and work through it. It does not act "right" if you just open frmInspectMill and try it from there.
...............when I added the coil and started to select values from your combo boxes then it worked and assigned the value to the textboxes for Coil_PK and InspectionEvent_PK.
the textbox for Inspection Event PK should be populated the moment that frmInspectMill is opened.
txtCoilNumber_PK would not be filled until either 1) the AfterUpdate event of txtCoilNumber finds and retrieves the CoilNumber PK ID from tblCoils and places it in txtCoilNumber_PK OR 2) the coil is not found and frmCoilStatus is opened to add a new coil, the coil is added; the button "Use This Coil" is clicked which closes frmCoilStatus, and returns to frmInspectMill (which is still open and never closed) and places the coil number in txtCoilNumber (assuming its not still there) and the PK ID of the coil in txtCoilNumber_PK.
Currently #1 does not work for me but #2 does work by using OpenArgs to open frmCoilStatus and returning the required values to frmInspectMill via form control references.
For #2, when a coil is not found and needs to be added, I've checked all of the underlying tables and the new and correct records are in place which tells me I can put my own value in txtCoilNumber_PK on frmInspectMill.
What I cannot figure out is in the case of #1 - when a coil already exists how to get and place the value of a coils PK ID from tblCoils and place that value in txtCoilnumber_PK.
Hope your quarantine is not driving you too nuts. It's a challenge here as well. I'm still at work but am very able to isolate and now the owner is having the office I share with two other inspectors professionally disinfected every 48 hours. This is nuts. Hopefully my little challenge is a distraction for you.
Thanks for your help!
Tim