Avatar of Sandra Smith
Sandra Smith
Flag 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
Microsoft ApplicationsMicrosoft DevelopmentMicrosoft Access

Avatar of undefined
Last Comment
Sandra Smith

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Jeffrey Coachman

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
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.
Jeffrey Coachman

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
Jeffrey Coachman

Great!

Glad I could help...

Happy Holidays!

Jeff
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Jim Dettman (EE MVE)

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

Jim.
Sandra Smith

ASKER
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