Exit users via code. Is it possible?

Carl_R

Registered User.
Local time
Today, 11:08
Joined
Aug 16, 2002
Messages
82
I have an Access97 DB which does not use security.

Through code, is there a way to force users out of the app?
 
Quickest way I can think of off the top of my head would be to have a table with one record with a simple checkbox.

Create your own little admin form with the option to remove all users and bind the checkbox to this table.

The idea I was thinking was to put some code on each form somewhere - possibly the Timer() event whereby you are checking to see if the checkbox is ticked and then run the close down function.

Then when you are ready to let them in, uncheck the box.

And also, on the switchboard's start check the checkbox to see if the box is already ticked and deny those people access.


Probably not the best solution but might be worth a try.
 
Hi Mile-O-Phile

I think I know what you mean. What I was after was a way to eject people once they are in the app.

We have an automated backup of the backend and it hasn't been working because users are leaving the app open when they go home.
 
Concur with Mile-o-Phile.

I use a startup form that doesn't exit when they click the exit button. Instead, it makes itself invisible and minimized. But the code underneath it is still running based on the timer event.

When my users enter the app, this code logs their entry. When they leave the app, it logs their departure. There is no reason why you couldn't include some timer code that once every minute or so, does a DLookup on a hidden table that is read-only to everyone except the Admins group members. Include some parameters in this table, such as "APP_LOCKED" Yes/No. (You can define other things if you wish and if they are appropriate.)

Then, if your timer code detects the appropriate setting of your chosen lock variable, it just does a DoCmd.Quit or something equivalent.
 
Hi The-Doc-Man

I see now. Looks pretty straight forward. I'll give it a crack.

Thanks to you both.
 
You could attach some code to the On Timer event of a hidden form at startup that checks if the DB has been idle for a specified time.

Create an unbound form and put this code in the On Timer event. In the AutoExec macro, open the form as hidden.

Set the following form properties:
'OnTimer: [Event Procedure]
'TimerInterval: 1000

'NOTE: The TimerInterval setting indicates how often (in milliseconds) the application checks for user inactivity. A setting of 1000 equals 1 second.

Sub Form_Timer()
' IDLEMINUTES determines how much idle time to wait for before
' running the IdleTimeDetected subroutine.
Const IDLEMINUTES = 1 (Your time in minutes)
Static prevcontrolname As String
Static prevformname As String
Static expiredtime
Dim activeformname As String
Dim activecontrolname As String
Dim expiredminutes
On Error Resume Next
' 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 Sub

Place this code in a module.

Sub IdleTimeDetected(expiredminutes)
'Message shown when idle time detected.
'
Dim Msg As String
Msg = "No user activity detected in the last "
Msg = Msg & expiredminutes & " minute(s)!"
MsgBox Msg, 48
'
'Close and quit application
'

Application.Quit acSaveYes

End Sub

Now, when there is no activity for the specified number of minutes, a message appears, and closes the application.
David
 
Hi DJN

This works a treat :)

I removed the msgbox from the module as this would require the user to click 'ok', which sort of defeats my purpose.
Now, they just get ejected.

Thanks a heap.
 

Users who are viewing this thread

Back
Top Bottom