Link to home
Start Free TrialLog in
Avatar of Sandra Smith
Sandra SmithFlag for United States of America

asked on

Log users in ACCESS 2003 to a text file

I have been trying to find the code that, when a user logs into an ACCESS 2003 database, this users information is logged to a an external text file.  I do not want it to be tracked in the database itself, but I want it to append to a text file.  Any direction on this would be appreciated.

Sandra
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sandra Smith

ASKER

Actually, this worked out just waht I wanted.  With a little tweaking, it appends the data as I want.  thank you

Sandra.
You can get the current user name with the CurrentUser Function:
    CurrentUser()

So you would change my code above to something like this:

Private Sub Form_Open(Cancel As Integer)
Dim FileN As Integer
FileN = FreeFile
         Open "c:\YourFolder\DBLogFile.txt" For Append As FileN
            Print #FileN, Chr(13) 'Carrige Return
            Print #FileN, CurrentUser()
            Print #FileN, Format(Now(), "mm-dd-yyyy hh:nn:ss")
        Close FileN
End Sub

If you are looking for the Network Log In, use a function like this:
http://access.mvps.org/access/api/api0008.htm
...then change the code accordingly.

JeffCoachman
Great!

Glad I could help...

Happy Holidays!

Jeff
Use the network login; without User Level Security in Access, every call to CurrentUser() will return 'admin', which makes it worthless.

Jim.
I have been using the Network login.  I have a function that returns this as we cannot use User Level Security where I am so all my databases relay on the Network login.  Thank you both for your advice.

Sandra