markcrobinson
Registered User.
- Local time
- Today, 05:10
- Joined
- Nov 28, 2017
- Messages
- 14
I would be interested in a discussion as to when it's best to use a macro vs. VB program.
<DataMacros xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application">
<DataMacro Name="[COLOR="DarkOrchid"]macWriteAuditRec[/COLOR]">
<Parameters>
<Parameter Name="parmTableName" Description="name of table where action occurred"/>
<Parameter Name="parmFieldName" Description="name of field in table where action occurred"/>
<Parameter Name="parmActionCode" Description="action being logged CREATE, UPDATE, DELETE"/>
<Parameter Name="parmOldValue" Description="old value of Field"/>
<Parameter Name="parmNewValue" Description="new value of Field"/>
<Parameter Name="parmChangedBy" Description="logon id of user who actioned this change"/>
<Parameter Name="parmChangedDate" Description="Timestamp of this action Now()"/>
<Parameter Name="parmRecordID" Description="RecordID of record being actioned (the PK-- this was an experiment)"/>
</Parameters>
<Statements>
<Comment>Named Macro to write audit log info into tblAuditLog
13-May-2017 NOTE:: You can copy a named macro via the immediate window using SaveAsText acTableDataMacro, "yourTableName", "Your directory and Filename and extension"
My example: SaveAsText acTableDataMacro, "tblAuditLog", "C:\users\mellon\documents\macWriteAuditRec.txt" and
you can print the xml tree formatted using Notepad++ with XML plugin.</Comment>
<DataMacros xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application">
<DataMacro Event="[B]AfterInsert[/B]">
<Statements>
<Action Name="RunDataMacro">
<Argument Name="MacroName">tStudent.[COLOR="YellowGreen"]macAuditTStudent[/COLOR]</Argument>
<Parameters>
<Parameter Name="parmActionCode" Value=""CREATE""/>
<Parameter Name="parmRecordID" Value="[StudentID]"/>
</Parameters>
</Action>
</Statements>
</DataMacro>
<DataMacro Event="[B]AfterUpdate[/B]">
<Statements>
<Action Name="RunDataMacro">
<Argument Name="MacroName">tStudent.macAuditTStudent</Argument>
<Parameters>
<Parameter Name="parmActionCode" Value=""UPDATE""/>
<Parameter Name="parmRecordID" Value="[StudentID]"/>
</Parameters>
</Action>
<Comment>After Update of tStudent</Comment>
</Statements>
</DataMacro>
<DataMacro Event="[B]AfterDelete[/B]">
<Action Name="RunDataMacro">
<Argument Name="MacroName">tblAuditLog.macWriteAuditRec</Argument>
<Parameters>
<Parameter Name="parmTableName" Value=""tStudent""/>
<Parameter Name="parmFieldName" Value=""SLastName""/>
<Parameter Name="parmActionCode" Value="[parmActionCode]"/>
<Parameter Name="parmOldValue" Value="[Old].[SLastName]"/>
<Parameter Name="parmNewValue" Value="[SLastName]"/>
<Parameter Name="parmChangedBy" Value="fosusername()"/>
<Parameter Name="parmChangedDate" Value="Now()"/>
<Parameter Name="parmRecordID" Value="[parmRecordID]"/>
</Parameters>
<ConditionalBlock>
<If>
<Condition>[IsInsert]</Condition>
<Statements>
<Action Name="SetField">
<Argument Name="Field">DateCreated</Argument>
<Argument Name="Value">Now()</Argument>
</Action>
</Statements>
</If>
</ConditionalBlock>