Update Trigger

khurram7x

Registered User.
Local time
Tomorrow, 04:03
Joined
Mar 4, 2015
Messages
226
I've a requirement where I need Before and After Update triggers to be fired when an existing record is updated, but not when a new record is inserted. My understanding is that for insert operations we've Insert triggers.

Then why Update triggers are firing after Insert operation?? How to make them fire for Update operations only, and not for Insert operations please?

Thanks.
 
If you mean the update events of a form, you can test for a new record with:

If Me.NewRecord Then
 
If you mean the update events of a form, you can test for a new record with:

If Me.NewRecord Then
Thanks Paul, Me.NewRecord is a good idea but I don't know how to make rest of the code work in VBA. I only know how to use Macro's for now. I tried to use Convert From Macro's to Visual Basic, but something seems wrong and i see many 'Error$' messages in the code.

I've written a Macro to run on Before Update trigger which pops a MsgBox to ask user whether he wants the record to be updated. If no, it does Undo and CancelEvent, and in case of Yes, After Update trigger runs an action query to update another table. There's an independent After Insert event, but it has nothing to do with updates and should only trigger when new record is inserted.

Attaching screenshot, though not quite sure is it helpful or not.

Thanks.
 

Attachments

  • Before Update.JPG
    Before Update.JPG
    33.4 KB · Views: 93
  • Auto Generated Code.txt
    Auto Generated Code.txt
    4.2 KB · Views: 167
I don't use macros, but a quick search says this should work as the condition:

[NewRecord] = False

Or True of course, depending on how you want the logic to flow.
 
I don't use macros, but a quick search says this should work as the condition:

[NewRecord] = False

Or True of course, depending on how you want the logic to flow.
I know about False thing, but I was confused about converting Macro to VBA.
Here I just called Macro from VBA after passing the NewRecord condition.

It solved my problem, though initially i didn't get the idea.

Thank you.
 
Glad you got it working.
 

Users who are viewing this thread

Back
Top Bottom