Logging people of a databse idea ?

reddwarf

Registered User.
Local time
Today, 10:33
Joined
Dec 3, 2009
Messages
43
Hi guys

I am currently using this code to detect Idle time and auto log of users after 30 mins if they have had ZERO DB activity.

http://support.microsoft.com/?id=210297

it works a treat - even if the back end corrupts wich saves me loads of time as we have 100 users and most if not all always forghet to log off !

however, i have had an idea and i wanted a second opinion before i got the work started. using this code, could i set up a new table called tbllogoff and have one field in it - LOGG_OFF. this is set to NO as default.

then modify the code above with an IFF statement at the top to first look at this table and check the value of this field - if it = YES then run the IDLETIMEDETECTED producre and quit the application.

then i could simply go into the back end, change the VALUE TO yes on my tlblogoff.LOGG_OFF field and it will automatically shut down all users in the database - also running the save command first : )

any thoughts on this - would it work ? has it been done before ?


cheers

DARREN
 
by the way this works......I can now remotely REMOVE USERS FROM THE DATABASE simply with out alot of fuss. let me know if you want code and workings.
 
RD I am sure plenty of people would be very interested in your results as this is a question that comes up regularly.
 
here you go !

1 : follow the work here by the MS engineers.
http://support.microsoft.com/?id=210297


2 : then CREATE A NEW DATABASE called LOGOFF ( call it what you want ). Save it in the folder with your back end.

In this DB simply create 1 table called "tbllogoff". In this table create 1 field called LOGOFF with a lookup field of either YES or NO. let acces set the rpimary key for ease which will be ID. then set the DEFULT VALUE to

="NO"

Save it and you done here.

then in your FRONT END - LINK THIS TABLE into it.

3 : MODIFY THE CODE ON THE DetectIdleTime FORM to this :

Private Sub Form_Timer()
' IDLEMINUTES determines how much idle time to wait for before
' running the IdleTimeDetected subroutine.
Const IDLEMINUTES = 30 'here you can set how long you allow idle time
Static PrevControlName As String
Static PrevFormName As String
Static ExpiredTime
Dim ActiveFormName As String
Dim ActiveControlName As String
Dim ExpiredMinutes
Dim myvar As String

On Error Resume Next

'HERE IS THE MODIFIED SECTION OF CODE !!!!

'I am calling my var the value of the field 1 in my log off table
myvar = DLookup("logoff", "tbllogoff", "ID = 1")
'now i will check if myvar = yes
If myvar = "YES" Then
'if it does then i will call my subroutine to QUIT the applcation
IdleTimeDetected ExpiredMinutes
Else
'if not then i will simply carry on checking if we have idle time

' Get the active form and control name.
ActiveFormName = Screen.ActiveForm.name
If Err Then
ActiveFormName = "No Active Form"
Err = 0
End If
ActiveControlName = Screen.ActiveControl.name
If Err Then
ActiveControlName = "No Active Control"
Err = 0
End If
' Record the current active names and reset ExpiredTime if:
' 1. They have not been recorded yet (code is running
' for the first time).
' 2. The previous names are different than the current ones
' (the user has done something different during the timer
' interval).
If (PrevControlName = "") Or (PrevFormName = "") _
Or (ActiveFormName <> PrevFormName) _
Or (ActiveControlName <> PrevControlName) Then
PrevControlName = ActiveControlName
PrevFormName = ActiveFormName
ExpiredTime = 0
Else
' ...otherwise the user was idle during the time interval, so
' increment the total expired time.
ExpiredTime = ExpiredTime + Me.TimerInterval
End If
' Does the total expired time exceed the IDLEMINUTES?
ExpiredMinutes = (ExpiredTime / 1000) / 60
If ExpiredMinutes >= IDLEMINUTES Then
' ...if so, then reset the expired time to zero...
ExpiredTime = 0
' ...and call the IdleTimeDetected subroutine.
IdleTimeDetected ExpiredMinutes
End If
End If
End Sub


Sub IdleTimeDetected(ExpiredMinutes)
DoCmd.Save
Application.Quit acSaveYes
End Sub


4 : your done.

So - here it how it works.

Firstly,

If a user is IDLE for 30 mins or more then the application wil quit. simples.

ALSO

if you open up the new DB you have created and CHANGE THE VALUE of the LOGOFF filed in the tbllogoff table to "YES" - as if by magin - everyone will be kicked out of the DB and you can compact and repair to your hearts content.

the reaosn you have to create a new DB is so if your main Be corrupts you can still get into the tbllogoff to kick everyone out. leaving your free to repair it.

I have test this as much as i can at present but it goes live tomorrow morning. I will let you know if it blows up !

Anyone got any thoughts ? ( p.s sorry about spelling, in a proper rush as got loads to do ! )
 

Users who are viewing this thread

Back
Top Bottom