How to Log Field Changes in a Microsoft Access Database
Question details
The user needs to record changes made to specific fields in a primary table to maintain an accurate audit history.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Creating an audit trail to monitor database updates, capturing old and new values whenever a user modifies a field.
- Observed behavior
- The user wants an automated tracking system to capture the previous value, updated value, timestamp, and user information when data edits occur in the database.
Before applying data macros or VBA code, create a complete backup of your Microsoft Access database (.accdb file) to ensure you do not lose data if the new event logic malfunctions.
Method 1: Create an Audit Trail Using Access Data Macros
Data macros are the most robust method for logging changes because they operate at the table engine level, successfully capturing edits made through forms, queries, VBA, or direct datasheet edits.
Introduced in Access 2010, Data Macros behave similarly to SQL Server triggers. By attaching a macro directly to the table's After Update event, you ensure no changes slip through unrecorded.
Design a new table named 'AuditLog'. Add fields for AuditID (AutoNumber), RecordID (Number), FieldName (Short Text), OldValue (Short Text), NewValue (Short Text), ChangedBy (Short Text), and ChangedDate (Date/Time).
Open the table you want to monitor in Datasheet view. On the Ribbon, select the 'Table' tab, and click on 'After Update' in the 'Table Events' group.
In the macro designer, add an 'If' block. Use the Updated("YourFieldName") function as the condition to check if a specific field's data was modified during the update.
Inside the If block, add a 'CreateRecord' action pointing to your 'AuditLog' table. Use 'SetField' actions to map data: Set [OldValue] to [Old].[YourFieldName] and [NewValue] to [YourFieldName].
Save and close the macro. Open your primary table, modify the tracked field, and then check the AuditLog table to verify the previous and new values were properly recorded.

Method 2: Track Changes Using Form Events (VBA)
If you only want to track changes made by users through a specific data entry form, you can use VBA to compare the control's value when the user enters it versus when they exit it.
Switch to WPS Office for Lightweight, Free Productivity
While Microsoft Access handles complex relational database tasks, your daily productivity involves documents, spreadsheets, and presentations. WPS Office offers a free, lightweight, and highly compatible alternative to the broader Microsoft Office suite, designed to streamline your daily workflow without hefty subscription fees.
- 1. Download the Installer: Visit the official WPS Office website and download the free installer package for your operating system.
- 2. Install WPS Office: Run the setup file and follow the quick on-screen instructions to install the comprehensive suite.
- 3. Open Your Files Seamlessly: Double-click any existing Word, Excel, or PowerPoint file to open and edit it directly within WPS Office with full formatting preserved.

Frequently Asked Questions
Can I log changes made directly to the Access table bypassing the form?
Yes. If you use Data Macros (introduced in Access 2010), changes are tracked at the database engine level. This means modifications made via forms, queries, VBA code, or direct datasheet edits will all trigger the macro and be logged successfully.
What information should I include in my audit log table?
A standard audit log table should include a unique AuditID, the primary key of the modified record, the field name that was changed, the old value, the new value, the timestamp of the change, and the username or ID of the person making the edit.
Will tracking field changes slow down my Access database?
Extensive auditing can marginally increase processing time and database file size because every update triggers a new write operation to the audit table. It is best practice to only log critical fields to maintain optimal performance and periodically archive old audit logs.
How do I capture the current user's name in an Access data macro?
Data macros run independently of the user interface and cannot directly read Windows usernames via the Environ() function. You typically need to capture the username at login into a TempVar, which the Data Macro can then read when writing to the audit log.




