Link to home
Create AccountLog in
Avatar of kittenwhisky
kittenwhiskyFlag for United States of America

asked on

" add a new record " event

I need to run a procedure when a new record is added to a table through a form.
Into which form event do I need to place the call to the procedure in vba?
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
"in other words, it fires as soon as you begin typing into a New record."
Ahh ... that's not the case.  BeforeInsert is the event that fires as soon as any bound control is changed on a New Record.  

Afterinsert fires once (after)the Record is Saved, preceded by the normal AfterUpdate event.  Hence the prefix 'After'

From this link:

http://office.microsoft.com/en-gb/access-help/order-of-events-for-database-objects-HP005186761.aspx

"Creating a new record    

When you move the focus to a new (blank) record on a form and then create a new record by typing in a control, the following sequence of events occurs:

Current (form) ¿ Enter (control) ¿ GotFocus (control) ¿ BeforeInsert (form) ¿ AfterInsert (form)

The BeforeUpdate and AfterUpdate events for the controls on the form and for the new record occur after the BeforeInsert event and before the AfterInsert event."

mx

Thanks for catching that. I was not thinking too clearly after only 1.5 quarts of coffee!
I wonder if the OP tested the solution ?

:-)

mx
The BeforeUpdate suggestion would work.