Solved

Log users in ACCESS 2003 to a text file

Posted on 2012-12-24
6
634 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

831 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