Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which event to call code on record insert?

Status
Not open for further replies.

ksbigfoot

Programmer
Apr 15, 2002
856
CA
I am using MS Access 2003.
I have 2 subforms on my page.
The first subform, when a record is inserted, I have to read the ID value of that record and then call some code that will automatically insert records into the 2nd subform. In the first subform the ID value isn't commited to the table until the "AfterUpdate" event. So I put my code in the AfterUpdate event to populate the 2nd subform. This isn't working as there are other fields in my record that the user can update later on and it calls the code in the AfterUpdate event, which I don't want it to fire.

My problem is that I only want to populate the 2nd subform only when an Insert occurs. Keeping in mind, I need the ID value of the first record in order to insert records into the second subform.

How would I only call code when a record is inserted with the ID of the record just inserted?
Thanks
 
Sorry, must of been tired. Since my AfterUpdate event fired before the AfterInsert event, I moved the code to the AfterInsert event and I was still able read the ID value.
Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top