Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time out if user is not active

Status
Not open for further replies.

pwrgek

Technical User
Sep 30, 2003
15
0
0
US
I would like to set up my database so that it will log a user out if inactive for say 5 min. Does any one have any ideas on how this can be done?
 
You might be able to use several Form Properties and Events to do this. The Load to set the timer interval, the Timer to run the interval, and the MouseMove and KeyPress to look for activity. A basic code might be:
Code:
Private Sub Form_Load()

    Me!clock = Now
    TimerInterval = 1000

End Sub
Sub Form_Timer()

    Me!clock = Now
    
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
'Code to reset timer
Me!clock = Now

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

'Code to reset timer
Me!clock = Now

End Sub
I'm not sure how the Key and Mouse events actually work, so you might have to play around with Select Case and/or If...then statements. Also, I don't know if such Events will lock up forms or slow processing down. I haven't tried it.

Hope that helps.


DreamerZ
 
Where is your database stored (how is it accessed by users) and how do users "log in"?

There's always a better way. The fun is trying to find it!
 
They log in using a form that checks for a matching password on a table. The data is stored in a seprate database than the front end. I have a hidden form that is always open and I will be adding a table to track when people login and out.
 
I guess maybe I should have been a little more specific with my questions...

Is your database on a web server (web page accessed via the internet) or on a local network?

There's always a better way. The fun is trying to find it!
 
Local network at this time. i may change it over to web in the future.
 
I've been thinkin g about this and I don't think you can do this in a practical sense. Here's my thinking... first, you'd have to have a method to determine what "inactivity" means - data entry, query, whatever. Easy to do from within the database, for the most part, but then you have to be able to do this for every potential user.

Then there's the problem of multi-tasked users. What if a user makes a single query and then spends the next 20 minutes entering parts of the query into another document; or answering the phone; or just scrolling the data. All of this would be undetectable by your database and would be considered "inactivity" when, in fact, it really wouldn't be.

I think maybe you should back up a little and rethink the need to log a user off for inactivity. Is there a pressing need to do this? Are resources limited?

If you did this as a web service, you could use sessions but it wouldn't actually indicate inactivity, just a time span that would log th euser off after a period of time or when certain conditions weren't met.

There's always a better way. The fun is trying to find it!
 
The main concern is speed the more people in the slower it is. However I have started exploring other ways to speed it up and this may not be the direction I want to go. I think we may move to the information being stored localy then updated once on close this will put less demand on the server and bandwith. Thank you for the help.

If you think of anything else let me know.

 
What DBMS are you using? This may have a lot to do with the problem. However, there shouldn't be a speed problem unless everyone is working on the tables at the same time. If you've got 10 users connected and only 1 doing any work, then you need to look at the DMBS itself and it's capabilities to operate in a client-server environment.

There's always a better way. The fun is trying to find it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top