How to list DataMacro objects in an Access database?

Can I programmatically list Data Macros in an Access 2010+ database? If so, how?


Note : Data macros are trigger procedures created in the table designer user interface context. They were new in Acces 2010. They are not the same as regular macros that are easy to list.

They have their own new AcObjectType enum AcObjectType : acTableDataMacro , but I cannot find another aspect of the Access object model or DAO that relates to them. They do not even appear in the MSysObjects table.

+3
source share
1 answer

This code will export the DataMacro metadata into an XML document ( Source ):

 Sub DocumentDataMacros() 'loop through all tables with data macros 'write data macros to external files 'open folder with files when done ' click HERE ' press F5 to Run! ' Crystal ' April 2010 On Error GoTo Proc_Err ' declare variables Dim db As DAO.Database _ , r As DAO.Recordset Dim sPath As String _ , sPathFile As String _ , s As String ' assign variables Set db = CurrentDb sPath = CurrentProject.Path & "\" s = "SELECT [Name] FROM MSysObjects WHERE Not IsNull(LvExtra) and Type =1" Set r = db.OpenRecordset(s, dbOpenSnapshot) ' loop through all records until the end Do While Not r.EOF sPathFile = sPath & r!Name & "_DataMacros.xml" 'Big thanks to Wayne Phillips for figuring out how to do this! SaveAsText acTableDataMacro, r!Name, sPathFile 'have not tested SaveAsAXL -- please share information if you do r.MoveNext Loop ' give user a message MsgBox "Done documenting data macros for " & r.RecordCount & " tables ", , "Done" Application.FollowHyperlink CurrentProject.Path Proc_Exit: ' close and release object variables If Not r Is Nothing Then r.Close Set r = Nothing End If Set db = Nothing Exit Sub Proc_Err: MsgBox Err.Description, , _ "ERROR " & Err.Number _ & " DocumentDataMacros" Resume Proc_Exit Resume End Sub 

EDIT: Gord indicated that you want DataMacros to be contrasted with standard macros. I found the code and tested it (it works) here

I tested the top function when you follow this link and it stores information about your table macros for each table in an XML document. It works well, supports the one who wrote it.

+2
source

All Articles