1

i am new to data macro in ms access 2013 and need some help with it. so lets assume that i have a simple database with only one table of Users. when i change the "Age" Field in the table, i want to run an external exe file (the reason why dosent matter). so i learn the subject during the last few days and end up with this: 1. i build a module in ms access called RunMiniFix (MiniFix is the name of the exe file i want to run). the module uses ShellExecute function and the whole module looks like that:

Option Compare Database
Const SW_SHOW = 1
Const SW_SHOWMAXIMIZED = 3

Public Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" 
  (ByVal hwnd As Long, _
   ByVal lpOperation As String, _
   ByVal lpFile As String, _
   ByVal lpParameters As String, _
   ByVal lpDirectory As String, _
   Optional ByVal nShowCmd As Long) As Long

Public Function RunMiniFix()
     Dim RetVal As Long
     On Error Resume Next
     RetVal = ShellExecute(0, "open", "C:\Program Files\MiniFix\MiniFix.exe", "<arguments>", _
                        "<run in folder>", SW_SHOWMAXIMIZED)
End Function

Now, when activating the module, everything works just fine and the exe file is running.

  1. in ms access, i build a data macro based on an 'If Then' statement, asking if [Users]![Age] > x and then calls the build-in RunCode event from the action catalog which calls the RunMiniFix function. Now, when saving the data macro, the ms access pops up a message box saying Microsoft access dosen't have the ability to find the name "Users" i mentioned in the phrase and recommend me to look for the right control in the form. "the form"? yes, the form! this database is not form based. i have no gui designed what so ever. i have no buttons or click event to handle. what i am asking is how can i trigger the RunMiniFix module when the Age field is modify. please, this is very important!

    thanks a head,

    oron.

braX
  • 11,506
  • 5
  • 20
  • 33
oron
  • 13
  • 3

1 Answers1

0

Please use SetLocalVar from the action list in data macro and set the expression to name of your function. Sample:

name: "test"
Expression: RunMiniFix()
MarredCheese
  • 17,541
  • 8
  • 92
  • 91
  • thanks hassan you helped me a lot. although i must ask, is there a way of doing it in ms access 2007? – oron Jul 05 '15 at 07:49
  • o.k, now i have another question... i'm trying to change the field value in the access database using winform application in vb.net. when the field changes through the application nothing happend. when i change the field manually through the database, then it fire the function. why is that and how can i solve it? thanks a lot! – oron Jul 05 '15 at 08:52
  • Programmatic edits to data does not trigger events. – June7 Oct 02 '19 at 20:41