Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to execute VBA code when specific tables and fields in a Microsoft Access database are updated?

Tags:

vba

ms-access

I have a program that uses a Microsoft Access database for its back-end. I need to have some VBA code (that calls a web service) execute whenever specific tables/fields are updated by the program. I see this working just like a trigger in SQL Server.

Is it possible to monitor for and act upon changes like this in Access?

Update The program in question does not run inside of Access (i.e. not a VBA app), it simply uses an MDB file as its back-end storage. Unfortunately I don't have access to the program's code as it is a closed third party application.

like image 627
joshuapoehls Avatar asked Jun 04 '09 18:06

joshuapoehls


People also ask

How do you update a record in Access VBA?

Go to the record that you want to change. Use the Edit method to prepare the current record for editing. Make the necessary changes to the record. Use the Update method to save the changes to the current record.


1 Answers

This question is old, but the answers are no longer correct. Access 2010 added data macro events that can be run when data is inserted, updated or deleted. The following events are available while using either the table datasheet view or table design view (events are attached directly to table and not through the form macro button):

  • After Delete Macro Event
  • After Insert Macro Event
  • After Update Macro Event
  • Before Change Macro Event
  • Before Delete Macro Event

More information is located here:

  • https://msdn.microsoft.com/en-us/library/office/dn124692.aspx
  • https://support.office.com/en-us/article/Create-a-data-macro-b1b94bca-4f17-47ad-a66d-f296ef834200
like image 189
manotheshark Avatar answered Oct 17 '22 20:10

manotheshark