capturing current user's username

slsy1212

Registered User.
Local time
Today, 16:09
Joined
Sep 1, 2004
Messages
13
i've posted a thread about this before - i need to capture the username of the person currently logged in to record who made which entry, and previously i just used a query to extract the username, with Environ("username") as the criteria, and it used to work, but now i'm using an updated version of the db, but that doesn't work anymore! and i can't figure out why!

and on top of that, as in my previous post, i need to capture the user who made that entry, and assign that value of the username to that field in that entry in that table and freeze so it doesn't keep looking up the current username in the query and keep changing it.

i'm in access hell! hope someone can help with this, thanks!
 
You haven't got a log in form set up so the users have to login before they get access to the db????

As to the assign, you need to check whether there is data already in the field - if not then assign the environ$...

As to the change, check with either the network people or by starting at 1 and counting up until an error in the debug window.

eg debug.print environ$(1)


Vince
 
errr... i do have a login form, and i'm quite a begginner in access so i'm not sure what you mean with the debug error thing... there must be another way to go about doing this?
 
Have a look at this thread

http://www.access-programmers.co.uk/forums/showthread.php?t=42154&highlight=fosusername

It uses an alternative to the Environ() method and all you need to do is call the Function to add the username to the table.

Another alternative is to search for "Audit Trail" as Ghudson has posted some excellent code for recording the new record / changes / edits etc who did it, date and time and the old and new values if anything is changed

Good Luck

Col
 
Thanks for the compliment Col. :D

slsy1212, you will have to add this public function if you are using Access 2003. The Environ function is on the bad list with the Sandbox mode.

Code:
'This function is used to allow the use of the Environ function in Access 2003
    
Public Function Environ(Expression)
On Error GoTo Err_Environ
        
    Environ = VBA.Environ(Expression)
    
Exit_Environ:
    Exit Function
    
Err_Environ:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_Environ
    
End Function
 

Users who are viewing this thread

Back
Top Bottom