how to make lastlogin date & time

SalmanZeiad

Member
Local time
Today, 02:51
Joined
Oct 30, 2017
Messages
115
i want to make form display in text box last login or entered to form
 
Describe more exactly where you are stuck in accomplishing that task.
 
Describe more exactly where you are stuck in accomplishing that task.
i want to add for example ,"last login :1-1-2026" to my login form
 
You didn’t add much detail however you can add a text box with a Control Source like:
=DMax(“DateFieldName”, “TableName”)
 
Well, first you need to store this data.
Then when you login, you look for that data.
I would use a record for each login, so you can DMax() on the DateTime, then store a new record as you log out, or even as soon as you log in.
 
Further to what has been suggested, you need a table called something like "tblLogin". It will need fields like "Login" and "LoginDateTime". In an AuthoExec macro, call a function that captures the UserID of the person starting the application and the date and time of that login. Store that in your Login table. From that data, retrieving the most recent login for each user is straightforward using DMax().
 
Further to what has been suggested, you need a table called something like "tblLogin". It will need fields like "Login" and "LoginDateTime". In an AuthoExec macro, call a function that captures the UserID of the person starting the application and the date and time of that login. Store that in your Login table. From that data, retrieving the most recent login for each user is straightforward using DMax().
I would retrieve before storing, else you will always get the current login?
 
i want to add for example ,"last login :1-1-2026" to my login form

You have gotten several responses. I will explain a fine point to help you go forward in this issue.

Access is a bare-bones rapid application development system that gives you the tools to do things you want done. With VBA you can be very flexible. You can have all sorts of login and update and visitation statistics in history tables. BUT you have to build them yourselves. The basic rule is that if you want to be able to track something - like a login - you have to write code to STORE that login and define a place to keep that information for future use. For tracking logins, that usually means building a tblLoginHistory that tracks date and user ID for each login. It is possible to keep other things in that proposed table, but for VBA and Access, the rule is "You want it? You build it."
 
I was beginning to think it was post bait, as o/p has not bothered to come back.
However, I myself have managed to ask the same question twice, as my memory is so bad. :-(
 
You have gotten several responses. I will explain a fine point to help you go forward in this issue.

Access is a bare-bones rapid application development system that gives you the tools to do things you want done. With VBA you can be very flexible. You can have all sorts of login and update and visitation statistics in history tables. BUT you have to build them yourselves. The basic rule is that if you want to be able to track something - like a login - you have to write code to STORE that login and define a place to keep that information for future use. For tracking logins, that usually means building a tblLoginHistory that tracks date and user ID for each login. It is possible to keep other things in that proposed table, but for VBA and Access, the rule is "You want it? You build it."
Ok, i understood
 
@SalmanZeiad - I would imagine that in your last couple of years, you might have had other things on your mind, enough to have forgotten what you had asked before being visited by a local form of Hell on Earth. Don't worry about having forgotten.
 
i want to make form display in text box last login or entered to form
Just make sure your database has no X on teh upper right hand corner and must be exited using your custom Button instead.
part of Button code - make sure it logs user exit time in a table. then display later - simple
 
Just make sure your database has no X on teh upper right hand corner and must be exited using your custom Button instead.
part of Button code - make sure it logs user exit time in a table. then display later - simple

Rather than being dependant on the user clicking the button, another method is to open a hidden form at start-up, and leave this open for the duration of the session. The exit time can then be logged when the form is closed, so will be executed however the database is closed. It's not tamper proof of course, as a vexatious user can easily edit the UserLog table, but as, in the attached demo, neither the UserLog table or the frmHidden form appear in the navigation pane, users will not be able to open these objects from the navigation pane in the the day to day operation of the database. If this were an operational database rather than a demo, the navigation window would be hidden of course.

In the attached file, if you log in as Ken Sheridan (DBA), and then click the Continue to Data Objects button you'll be able to select the UserLog table and open it with full read/write permissions. You should see that it has recorded your login. If you log in as Fiona Sheridan, you'll be able to open the UserLog table in read only mode.
 

Attachments

Users who are viewing this thread

Back
Top Bottom