I have a navigation form which has buttons the end user clicks to update the database and run reports. I need to create an audit of who 'clicked' the button. I created an "on click" event for one of the buttons, I updated the properties of the navigation form to link to the auditlog table. Now, here's where I get stuck and I am new to this process of trying to insert records into a table using VBA. The Audit log table consists of 4 fields -- the key "EditRecordID" which is autonumbered, "Modified_On, Modified_by and FunctionPerformed.
The form has the 3 fields "modified_on, Modified_by and FunctionPeformed. FunctionPerformed is a fixed text field "updatebalances".
The code I created:
Private Sub Command505_Click()
Dim sql As String
Dim strLocation As String
Me.Modified_by = Environ("USERNAME")
Me.Modified_on = Format(Now(), "yyyy-MM-dd hh:mm:ss")
sql = "Insert into AuditLog Values('" & Me.Modified_by & "', '" & Me.Modified_on & "', '" & updatebalances & "');"
DoCmd.RunSQL strSql
End Sub
The error message: "run-time error '3129': Invalid SQL statement; expected 'delete', 'insert','procedure','select', or update
I think I'm close.... Can I get some help? Thanks in advance!