Trigger when ANY form control changes

X

XP

Using Office 2003 and Windows XP;

I have a form and controls on a multi-page tab control on the form that are
bound to a table.

I need a trigger to fire a subroutine if there is ANY change in ANY of the
form controls. My code will need to determine whether the change is an edit
to an existing record or whether it will result in a new record. And I need
it to distinguish between the two (i.e. edit or new).

I don't want the code to intercept anything or prevent anything. The
subroutines just do some housekeeping stuff under the covers like add the
date added vs. date updated, perform a basic calculation, get some user info,
etc.

What event or events would be best to harness for this?

Thanks much in advance.
 
D

Douglas J. Steele

Check the form's BeforeInsert (which only fires for new records) or
BeforeUpdate event (which fires for both new and changed records).

If you're using the BeforeUpdate event, you can tell if it's a new record
using the NewRecord property:

Private Sub Form_BeforeUpdate(Cancel As Integer)

If Me.NewRecord Then
' it's a new record
Else
' it's an update to an existing record
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top