creating an audit trail

action

Registered User.
Local time
Today, 19:22
Joined
May 29, 2003
Messages
89
I want to add an audit trail to an inventory update form.
The form allows the user update cost/sell and quantity. The update is "processed" via a cmdbutton with code that checks Gross Margins etc. I want to add to the code some way of writing the changes to an audit table. I have created a table "TblInventoryUpdateAudit" but am unsure the best way of creating a record in the table via code.

Any suggestions?

Cheers
 
On the Update event use DAO code or an append query to add data to your audit table.

docmd.openquery "YourAppendQueryName"

or

'be sure the DAO Library is set in Menu - Tools|References when
'your are in a module creating/editing code (References is not
'otherwise visible
dim db as dao.database
dim rs as dao.recordset
set db=currentdb
set rs=db.openrecordset("TblInventoryUpdateAudit",dbopendynaset)
rs.addnew
'hopefully your table has an autonumber key field
'recordset fields are numbered 0 through n
rs.fields(i) = me!FieldName
'repeat the foregoing for for each field i
'autonumber fields are automatically updated, you cannot modify them
'I commonly add current user and current date/time to know who
'created the record. sCurrentUser and dtCreated are fields in the table
rs!sCurrentUser=CurrentUser 'a system function
rs!dtCreated=Now() 'also a system function
rs.update
rs.close
db.close
set rs=nothing
set db=nothing
 
Thanks, got the idea with the 2nd option.
Cheers
 

Users who are viewing this thread

Back
Top Bottom