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

LAST EDIT BY 2

Status
Not open for further replies.

bkrampe

IS-IT--Management
Nov 30, 2006
77
US
Is there any way to report on a form when and who made the last edit? Even if i could just get a computer name as who, that would be good enough. Is it possible?
 
Not unless you have a field that is completed in an Update event.
 
I don't know much but this is what I did. It gives the user a chance to either discard changes or save changes to a record. If they choose to save changes it dumps the current date into the "last edit date" field.


Private Sub Form_BeforeUpdate(Cancel As Integer)

If MsgBox("Would You Like To Save This Record?", vbQuestion + vbYesNo + vbDefaultButton1, "Save This Record ???") = vbNo Then
Me.Undo
Else: [Last edit Date] = Date

End If
End Sub


Hope that helps somewhat.
 
you can access the windows environment varraibles, giving user name logged in, and computer name. I use then to keep an audit log of record changes myself.

The following code is an example of some of the variables available to you. You then will have to create your own code to capture the update event and change the [update date] and [username/computer name] values in the underlying table(which you will have to create as new fields.)

place this code in a new modlue and call it from the immediate window by typing the following:

Call DMS_EnvironVaraibles()

Code:
Public Function DMS_EnvironVaraibles()
    Dim User As String
    Dim user2 As String
    Dim computer As String
    Dim Domain As String
    Dim proc As String
    Dim os As String
    Dim windir As String
    Dim i As Integer
    
    User = Environ("USERNAME")
    Debug.Print "user =           " & User
    computer = Environ("COMPUTERNAME")
    Debug.Print "comp =           " & computer
    Domain = Environ("LOGONSERVER")
    Debug.Print "Logon server =   " & Domain
    Domain = Environ("USERDOMAIN")
    Debug.Print "user domain =    " & Domain
    proc = Environ("NUMBER_OF_PROCESSORS")
    Debug.Print "proc =           " & proc
    os = Environ("OS")
    Debug.Print "OS =             " & os
    windir = Environ("windir")
    Debug.Print "windir =         " & windir
    i = 1
    For i = 1 To 31
        Debug.Print i
        Debug.Print Environ(i)
        i = i + 1
    Next

End Function

you can even get all the windows server groups that a user is a part of.

.....
I'd rather be surfing
 
As you may be aware, Environ can be blocked as an unsafe expression in Access 2003 and above.
 
Ok i created the new module named fOSUserName. How much of the code was i supposed to put in there. I am wanting that when the ExpectedDoorDeliveryDate text box is edited it will put who edited it in txtUserName text box. What all do i need to change, and if i could have a little help with the coding. Thanks for all your help so far and yet to come
 
put all this:
Code:
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
    strUserName = String$(254, 0)
    lngLen = 255
    lngX = apiGetUserName(strUserName, lngLen)
    If ( lngX > 0 ) Then
        fOSUserName = Left$(strUserName, lngLen - 1)
    Else
        fOSUserName = vbNullString
    End If
End Function

then use an event, like on change, in the ExpectedDoorDeliveryDate text box.

Dim str user as string
user = fOSUserName()
me.txtUserName = nz(user,"")


.....
I'd rather be surfing
 
You can use the before update event:

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    Me!UpdDate = Now()
    Me!UpdatedBy = fOSUserName
End Sub
 
You can't have a procedure having the same name as a module, so rename the module.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Ok i got the username to report. Thank you all very much for all your help. Would there be any way to save like the last 5 people that edited that particular record? Just curious.
 
You could search for auditing:

[google]microsoft access auditing[/google]
 
Or add a timestamp and append...

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    me!updatelog=vbcrlf & me!updatelog & now() & ": " & fosusername
End Sub

SeeThru
Synergy Connections Ltd - Telemarketing Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top