Hello again everybody, I am looking for guidance here on an issue that has been plaguing me for the past few years.
Question:
How do I duplicate a set of records, then select the newly duplicated records, then update a field on only the newly duplicated records?
Context:
At this point, I am looking for guidance specifically on how to select newly duplicated records in VBA so I can append the C-ID field. Does anybody have any good examples or support articles showing how to achieve this?
Question:
How do I duplicate a set of records, then select the newly duplicated records, then update a field on only the newly duplicated records?
Context:
- I have a form called frmCertificates which uses tblCertificates as the record source.
- I have a subform on frmCertificates called sbfrmModels which uses tblModels as the record source.
- Each record in tblModels contains a field called C-ID, which is populated with the primary key from the certificate record in tblCertificates for which the model apperas on that certificate. I have a button on frmCertificates which allows a user to add a model to tblModels and it automatically populates the C-ID field to use the ID from the certificate record. This allows a user to add thousands of models to a certificate record.
- Whenever a certificate is updated, we need the ability to preserve the old certificate record to create a snapshot in time. So a new certificate record has to be created every time a change is made to that certificate. This can be cumbersome to users when a certificate has thousands of models and each model has to be manually added to the new certificate. So I want to create a function that allows a user to duplicate all of the models from the old certificate record and attach them to the new certificate record.
- I can successfully duplicate the certificate record in tblCertificates.
- I can also successfully duplicate all the records in tblModels whose value in C-ID matches the ID field from duplicated Certificate record in tblCertificates.
- Now, I need to select the newly duplicated records in tblModels and append the C-ID field to match the value of the ID field from the newly created record in tblCertificates. This is where I am struggling.
At this point, I am looking for guidance specifically on how to select newly duplicated records in VBA so I can append the C-ID field. Does anybody have any good examples or support articles showing how to achieve this?