Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logging users who change record 2

Status
Not open for further replies.

Howi

IS-IT--Management
Apr 12, 2001
76
GB
I need to record within a database the IP address of any user making a change to records or inputting new records together with the date of the change - can this be done?
 
I record user info when they input or change data via a form...

I forget where I found this, but it seems to work for me...

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty = True Then
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & "Do you wish to save the changes?"
strMsg = strMsg & " Click Yes to Save or No to Discard changes."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
'do nothing
Else
DoCmd.RunCommand acCmdUndo
Exit Sub

End If


Let Me.Date_Update = Date
Let Me.User_Update = Environ$("UserName")
End If
 
Brilliant - many, many thanks.
 
Howi,

If you click the link just above your name in the third post in this thread, RomanW1 will get a semi-official thanks, and it will go down on his (or her) personal record.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
for a somewhat more comprehensive approach, see faq181-291





MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
To pickup and use the windows logon id:
Create a module called: vbAPI

Function GetUserID()
' RMO, 2/3/98
' API to get the Username from the Windows registry
Dim strName As String
Dim lngSize As Long
Dim lngRetVal As Long
lngSize = 199
strName = String(200, 0)
lngRetVal = GetUserName(strName, lngSize)
GetUserID = UCase(Left(strName, lngSize - 1))
End Function


On your form
add an expression for save or change or whatever and call the function

Me.ChangedBy = CurrentUser


Thanks,
John McKenney
Work Hard... Play Harder
 
Michael nice FAQ; John nice addition for USER !!

Howi: Do you need a full audit log, i.e., the table & field old & new values or just to keep track of who does generic DML (UPDATE & INSERT) along with the timestamp.

If you just need to keep track of who's changing data, rather than audit the changes themselves, you could use the form AfterUpdate and AfterInsert events to INSERT user,dml_type, and timestamp into a changes table.

Jeffrey R. Roberts
Insight Data Consulting
Access, SQL Server, & Oracle Development
 
Quehay - We just need to know who makes changes etc
RomanW1's code seems to do the trick although we have ammended a little to insert date and time of change, username and computer name to make tracking easier for us.

many thanks to all who replied to my request
What a fantastic group.
 
To each their own, as they say, and hte code used is just to return the UserID to the from control, so we do not see how it is used, but many soloutions only record the "latest" User ID (generally kept within the single record. This quickly becomes more-or-less useless in any but the most cosmetic sense, as you cannot say with any certanity that the reorded user may any specific change which may be the subject of contention. Your ammendment (to include the date/time of the change) suggests that you are attempting to use the info for other purposes.





MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top