Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Track logged in Users
Brent Rinehart 
        
5 years ago
How easy would it be to track when a user logs into the database based of the username of the computer and when they shut the database down?
Richard Rost  @Reply  
          
5 years ago
Brent, you have my Security Seminar. All of that is covered in there. Username/password logon. Setting permissions. Logging activity. You could easily log when the Main Menu shuts down. But, if you want to just get the Username setting on that computer, you could read the Windows environment variable. I covered this in Access Developer 31.
Adam Schwanz  @Reply  
           
5 years ago
I seen the post topic and thought I was gonna get to come in here and praise how the Security Seminar is your best seminar in my opinion but you beat me to it :P.
Richard Rost  @Reply  
          
5 years ago
Yeah that's one of my favorites.
Brent Rinehart OP  @Reply  
        
5 years ago
Yes I would love to do a full blown user login but everyone has already complained about that so I just wanted to log in the background when user log on and of so I can see who is logged in at any given time and you used the database the most. but if the user has to do anything extra there will be complaints. I dont have D31 yet guess I will have to get that one next.
Scott Axton  @Reply  
        
5 years ago
Brent Check out the Get Username WScript in the code vault.  That might be enough based on what you indicated.
Brent Rinehart OP  @Reply  
        
5 years ago
I will look into that and I just bought D31 to I should be able to come up with something thanks Scott
Brent Rinehart OP  @Reply  
        
5 years ago
I was looking into the GetNetwork User Name Function in the code Vault and I got an error while running. I would assume the code is using something having to do with 32-bit since I am running 64-bit on my machine.

Brent Rinehart OP  @Reply  
        
5 years ago

Adam Schwanz  @Reply  
           
5 years ago
You should just be able to PtrSafe it 64-Bit Access
Richard Rost  @Reply  
          
5 years ago
If you have D31, the ENVIRONment variable works just the same, if not better.
Brent Rinehart OP  @Reply  
        
5 years ago
Good Evening Richard I thought I got the user logon tracking working it seems to work then I distributed to my team and it seems every time they open the database it seems that it is logging their login and log off but with my username. I am using a tempvar to pass the username to a global function, maybe somehow the tempvars variable is holding my name? I have never used tempvars this is the first so I dont really understand them. I am posting what I have created if you can point me in the right direction why it would capture all the log ins and log offs but dont the other users names that would be great.
Brent Rinehart OP  @Reply  
        
5 years ago
Global Module called ModUser
Public Sub Logging(Activity As String)

    CurrentDb.Execute "INSERT INTO ActivityLogT (LoggedUser, Activity) Values('" & TempVars("LoggedUser").Value & "', '" & Activity & "')"
    
End Sub

Public Function GetUserName() As String

    GetUserName = Environ("Username")

End Function
_________________________________________________________

Main Menu Form that stays Open

Private Sub Form_Load()
  DoCmd.ShowToolbar "ribbon", acToolbarNo
    TempVars("LoggedUser").Value = Me.LoggedUserTxt.Value
  
   ModUser.Logging "LogOn"

End Sub

Private Sub Form_Unload(Cancel As Integer)

    ModUser.Logging "LogOff"
  
End Sub
Brent Rinehart OP  @Reply  
        
5 years ago

Brent Rinehart OP  @Reply  
        
5 years ago
If anyone could point me in the right direction I would appreciate I have tried everything I know and still nothing seems to work.
Scott Axton  @Reply  
        
5 years ago
OK I'm going to ask a dumb question.  Are you actually using a different account to test with? Or are you just going to different machines and logging in as you?

If it is the latter the user would always be you.

Brent Rinehart OP  @Reply  
        
5 years ago
I send the front end file out to my colleges to see if it picks up their username which is is not doing, there is about 10 people that use the database and none of their names get picked up.
Scott Axton  @Reply  
        
5 years ago
OK try this in your load event on the Main Menu.  Note you really don't need " .value "

     TempVars("LoggedUser") = GetUserName

Then when you need to use the value in the Logged User:

    Dim LU as string  'LoggedUser

    LU = TempVars![LoggedUser]

Use the LU in place of the & TempVars("LoggedUser").Value & in your SQL string

I tried this in the Blank Template and the Status box but didn't create a Activity Log.  I think this will work though.
Brent Rinehart OP  @Reply  
        
5 years ago
Thank You for the help I will try that and distribute to my college tomorrow see if I can get it to work, really appreciate the help.
Brent Rinehart OP  @Reply  
        
5 years ago
Good Morning I wanted to report after trying what Scott recommended worked, it seems everything is working like it should thanks again Scott.
Scott Axton  @Reply  
        
5 years ago
WooHoo!!  

One problem down...  Now on to the next one.
I appreciate you letting me (us) know.  Some times people fix things and you never hear.

Richard Rost  @Reply  
          
5 years ago
Sorry I didn't see this sooner. Took a few days off last week. Thanks, Scott, for picking up my slack! :)

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/6/2026 8:31:02 AM. PLT: 0s