Solved

Log users in ACCESS 2003 to a text file

Posted on 2012-12-24
6
627 Views
Last Modified: 2012-12-26
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
0
Comment
Question by:ssmith94015
  • 3
  • 2
6 Comments
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 38719204
Do you already have a Log in system?
If so, what does this system track? (userID?, user Name?, Login date/Time?)

You can certainly create a system to open your main form, and trigger code to track this info to an external file:
1. Create a blank Log File:
Name: DBLogFile.txt
Contents: "DBLog File:"
Location: C:\YourFolder\

2. On the open event of the startup form do something roughly 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, strpubUserName 'This is a public variable the stores your login name
            Print #FileN, Format(Now(), "mm-dd-yyyy hh:nn:ss")
        Close FileN
End Sub

But you need to tell us a bit more about any existing system you have in place...


JeffCoachman
0
 

Author Closing Comment

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

Sandra.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38719227
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
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38719228
Great!

Glad I could help...

Happy Holidays!

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

Jim.
0
 

Author Comment

by:ssmith94015
ID: 38721135
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
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question