Audit Trail

gilescis

D. Castaldo
Local time
Today, 09:44
Joined
Jan 23, 2006
Messages
106
I have created the following code to put the date and username into a table to track any changes made to a record. All I am interested is when the change was made and by who.

When I change a record the Now() command works fine and puts the date and time but the Username = User_FX does not grab the logged in to win nt domain user any Ideas



Private Sub Form_BeforeUpdate(Cancel As Integer)
' Log the user details to the table
Me!SystemUsername = User_FX
Me!RecordChanged = Now()
End Sub


Thanks for the hlep
 
BTW Username and RecordChanged are both fields in a single table
 
What is User_FX?
 
I found this awhile back

Alternatives From Garry

Rather than saving the full record to another table, you can add 2 fields to the current table such as SystemUsername (text 50) and RecordChanged (date) and log the person who made the last change to that record. In the before update event, add the following code. This is less onerous to manage.

Private Sub Form_BeforeUpdate(Cancel As Integer)

' Log the user details to the table

Me!SystemUsername = User_FX
Me!RecordChanged = Now()

End sub

User_FX is a Toolshed function that retrieves the NT/Win XP user name. This will store that person who has logged for that records. You do not need to add the fields to the form to make this work.
 
Have you added that function?
 
gilescis said:
What do you mean added the function ?
If you refer to another function (user_FX) from within a function, then the user_FX function must be added to the database for it to work, otherwise it doesn't know what to do because its trying to find a function (user_FX) that doesn't exist.

Col
 
So is this an add-in I need to do or is this a programming function
 
I presume user_FX is a function within that sample database - have you checked that?

Col
 
No but i will thks

Is there any other way of grabbing the user info from the windows pc they are logged in without getting to complicated ?


Like i said the date works fine it just need to bring in the user that is in that database at that time
 
If it works (it won't) then it's correct. If it doesn't work, then it's not correct, and you should compare what you have to what Col posted, since they're different.
 
I'd like to piggy-back a quick question on here if I could...

In my Audit log I am adding in, I am noting record activity in a memo field in an Audit table. I am using VBA to note the following:

- Now()
- logged in user (by global variable) name
- Environ(user) name (or however that goes exactly)
- Field Update (only key fields are tagged with the audit VBA


Now, at the end of this string, I would like to add a line carriage so that the next entry is added onto a line of its own. How is this done?

Thank you.
 
put this in a module and run it - this will show you all the environ options - 33 i think

sub showenviron
dim x as integer
dim strg as string

for x=1 to 50
if len(environ(x))>0 then
strg = strg & vbcrlf & "Environ: " & x & " " & environ(x)
end if
next x
msgbox(strg)
end sub
 

Users who are viewing this thread

Back
Top Bottom