Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey guys!
so first thing first...
i have an access 2013 database (accdb) which hold single table, "Users".
using the data macro tool of ms access, i wrote an AfterUpdate data macro which call the 'SetLocalVar': the name i called it is 'Run' and the expression is a function i wrote in VBA, called 'ActivateSmsCenter()'. this function runs ShellExecute function that activate an exe file.
beside the database, i have a booking managment software that does manipulation on the database.
basically, i need whenever field is changing in the 'Users' table to run the AfterUpdate data macro.
Now, when i change a field manually through the database, the macro triggers.
if i change the field through my main software using OleDbCommand, the field changes but the macro wont fire. because of that, i needed to write 'RunMacro' function in my software which looks like this:
VB
Dim oAccess As Access.Application
oAccess = CreateObject("Access.Application")
oAccess.Visible = False
oAccess.OpenCurrentDatabase("C:\Users\oron\Desktop\DataBase Listening\LocalDB.accdb", False)
oAccess.Run("ActivateSmsCenter")
oAccess.DoCmd().Quit(Access.AcQuitOption.acQuitSaveNone)
System.Runtime.InteropServices.Marshal.ReleaseComObject(oAccess)
oAccess = Nothing

The problem is that this is a very bad idea. our software contains over 1.5 milion code line and i cant call this function in every function. i need it to be trigered automatically.
my Q is how can i fire the datamacro without calling the 'RunMacro' function or in other words, why my macro wont fire when changing the field using code?
thanks alot,
oron.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900