Solved

Log users in ACCESS 2003 to a text file

Posted on 2012-12-24
6
640 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

726 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