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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Who updated this record? How can I find this info? 4

Status
Not open for further replies.

applevacross

Technical User
Jul 14, 2005
41
US
Is there a way to find out who updated a record without having the person actually select their name from a list noting they updated that record? Reason being; my manager has requested I put this in the DB w/out the users knowing, (I guess he wants accountability).

Ex. John Doe opens the form and makes a change. He closes the form. My manager requests to find out who made the change. Is there somewhere I can check without the users knowing they've been recorded as the last person editing that specific record?

Is this possible? Would I have to create some kind of macro which would record this info? If so, is there anybody whose done this? I wouldn't even know where to begin. Please help, I don't code. Sorry.

Thanks to all in advance, I greatly appreciate it.
 
away you can do this is to use

environ("username")

this command takes the log in name of the user from the system,
I always add a username field in the table and use that command to pouplate the field, I normally stick a command like

me.username = environ("username")

in the after update of another field on the form.

Hope this is of use, Rob.[yoda]
 
Add 2 fields to the table, say:
LastUpdateDate (DateTime), LastUpdateUser (Text).
In the form add 2 hidden textbox bound to the above fields.
Then in the BeforeUpdate event procedure of the form:
Me![name of date control] = Now()
Me![name of user control] = Environ("UserName")

If the database is secured then use Application.CurrentUser to get the user name.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks Guys, I appreciate it. Though I do have a question for PH. The DB is secured. So should I use the procedure:

Application.CurrentUser within

Me![name of date control] = Now()
Me![name of user control] = Environ("UserName")

Thanks, that's why you guys are the pro's and I'm the novice.
 
Great tips!
Much beter than having the user ask his username (again) in the application.

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    Environ ("username")
    Me.Username = Environ("username")
    Me![LastUpdateDate] = Now()
End Sub

Pampers.

You're never too young to learn
 
The DB is secured
Me![name of date control] = Now()
Me![name of user control] = Application.CurrentUser

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
if you want just the date

use Date

if you want date and time then use

Now()

Rob.

Hope this is of use, Rob.[yoda]
 
Hi PH, here is the chunk of code from the vb editor on the before update procedures of both text boxes. I don't seem to be getting the data back at the table:

Private Sub Combo96_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Serial #] = '" & Me![Combo96] & "'"
Me.Bookmark = rs.Bookmark
End Sub

Private Sub Text105_BeforeUpdate(Cancel As Integer)
Me![Update By] = Application.CurrentUser
End Sub

Private Sub Text107_BeforeUpdate(Cancel As Integer)
Me![LastUpdateDate] = Now()
End Sub

Private Sub Update_Click()
On Error GoTo Err_Update_Click

Dim stDocName As String

stDocName = "SyncUpdateRecord"
DoCmd.RunMacro stDocName

Exit_Update_Click:
Exit Sub

Err_Update_Click:
MsgBox Err.Description
Resume Exit_Update_Click

End Sub

Thanks again for your help!
 
PHV said:
Then in the BeforeUpdate event procedure [highlight]of the form[/highlight]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Can I send you donations? It's people like you that will eventually make me like you. That's perfect. Sorry I'm learning the ropes. Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top