 |
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

October 15th, 2003, 03:10 PM
|
Registered User
|
|
Join Date: Sep 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Force users to exit access application
Is there a way to force all users out of an access application? We can't use a drone form or anything like that as the users are already in the DB. We just need a way to kill all sessions of the db.
|

October 15th, 2003, 03:14 PM
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am not familiar with the drone concept. Please explain.
Sal
|

October 16th, 2003, 09:35 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
Hello,
Here is an approach I picked up from F. Scott Barker. I use a simplified version of his method but its effective. Barker uses some custom database container properties (File->Database Properties->Custom to set a Boolean custom property in the backend db that administratorâs can toggle on and off, and that front-end applications can monitor periodically using a Timer event. If the property is toggled ON, code in the front-end apps executes an Application.Quit statement, after the proper notifications. The problem with this approach is that, if the backend db is corrupted, the dbâs custom properties wonât do you any good.
So Iâve just hard-coded the path to the backend db folder to simplify things in what follows. Here are the basic ideas:
1. Give the system admin a means of creating a hidden âflag fileâ (Logout.flg) in the folder that the backend resides in. (this is done using frmSystemUtilities below)
2. Create a hidden form in all of the frontend apps that is opened from your splash screen when the workstation apps are opened. Code behind the hidden âmonitorâ form checks periodically for the existence of the flag file using a Timer event. (frmLogoutMonitor below)
3. If the flag file exists (i.e., the admin has initiated a logout), have frmLogoutMonitor open a second form called frmLogoutCountdown. This form notifies users that they will be logged out in, say, 5 minutes, and includes a textbox that counts down the minutes until there application instance will quit.
4. You also need a method of canceling the logout if the admin decides to do so. This can simply be done by toggling the caption property on the command button placed on frmSystemUtilities which the admin uses to initiate the logout.
5. You also need 4 utility routines in a standard module (basGlobalUtilities) to handle the flag file creation and removal, check for its existence, and to check to see if frmLogoutCountdown is already open (i.e., a forces logout is underway), so you can close it if the admin cancels the logout.
*********
frmSplash
*********
Add the following code behind any splash screen to open the hidden monitor form. This form must remain open for the life of the session:
Private Sub Form_Load()
' Turn on the monitor form
DoCmd.OpenForm "frmLogoutMonitor", , , , , acHidden
End Sub
**********
frmMonitor
**********
Set the monitor forms timer interval property to 60000 (1 minute). The monitor form will check for the existence of the flag file once every minute. You can adjust this if performance suffers. Place the following in the monitor forms Timer event:
Private Sub Form_Timer()
' Does flag file exist. You are looking for it in the folder
' where you backend db resides. If it exists, open the countdown form.
If LogOutCheck("C:\Temp\Logout.flg") Then
If Not FormIsOpen("frmLogoutCountdown") Then
DoCmd.OpenForm "frmLogoutCountdown"
End If
Else
' If admin cancels logout, close countdown form.
If FormIsOpen("frmLogoutCountdown") Then
DoCmd.Close acForm, "frmLogoutCountdown"
Beep
MsgBox "The Logout Countdown has been canceled." & vbCrLf & _
vbCrLf & "You may go on with your work.", _
vbInformation, "Logout Canceled"
End If
End If
End Sub
******************
frmLogoutCountdown
******************
Place appropriate notification labels on this form, letting users know that they will be logged out in 5 minutes. Place a textbox on his form named txtMinutesToGo to display the countdown. Set frmLogoutCountdownâs Timer Interval property to 60000 also. Place this code behind frmLogoutCountdown:
Private mintCountDown As Integer
Private Sub Form_Open(Cancel As Integer)
mintCountDown = 5
End Sub
Private Sub Form_Timer()
' Decrement countdown textbox by 1 minute.
mintCountDown = mintCountDown - 1
If mintCountDown <= 0 Then
Application.Quit
Else
Beep
Me!txtMinutesToGo = mintCountDown
End If
End Sub
******************
frmSystemUtilities
******************
Create a form with a single command button on it. This form can only be accessed with an admin logon. The admin will click this button to initiate/cancel the forced logout. Set the buttons caption to âLog Users Out of Systemâ. Place the following in the command button's Click event:
Private Sub cmdLogInOut_Click()
If Dir("C:\Temp\Logout.flg", vbHidden) = "Logout.flg" Then
Call LogoutRemove
Else
Call LogOutCreate
End If
Call DisplayLogInOut
End Sub
Sub DisplayLogInOut()
If Dir("C:\Temp\Logout.flg", vbHidden) = "Logout.flg" Then
Me!cmdLogInOut.Caption = "&Allow Users Into System"
Else
Me!cmdLogInOut.Caption = "&Log Users Out Of System"
End If
End Sub
******************
basGlobalUtilities
******************
Now you just need the utility routines to create and remove the flag file, check to see if it exists, and check to see if frmLogoutCountdown is already open. Place the following in a standard module:
Function LogOutCheck(strBackEndPath) As Integer
On Error Resume Next
LogOutCheck = Dir("C:\Temp\Logout.flg", vbHidden) = "Logout.flg"
End Function
Function FormIsOpen(strFormName As String) As Integer
Dim frmCurrent As Form
For Each frmCurrent In Forms
If frmCurrent.Name = strFormName Then
FormIsOpen = True
Exit Function
End If
Next frmCurrent
End Function
Public Sub LogoutRemove()
On Error Resume Next
SetAttr "C:\Temp\Logout.flg", vbNormal
Kill "C:\Temp\Logout.flg"
End Sub
Public Sub LogOutCreate()
On Error Resume Next
' Create flag file
Open "C:\Temp\Logout.flg" For Output Shared As #1
Close #1
SetAttr "C:\Temp\Logout.flg", vbHidden
End Sub
I think that covers all the bases. Let me know if you need clarification on anything.
HTH,
Bob
|
The Following User Says Thank You to Bob Bedell For This Useful Post:
|
|

October 21st, 2003, 08:46 AM
|
Registered User
|
|
Join Date: Sep 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for the suggestion, however this is pretty much the drone concept I was talking about. I need to be able to close everyone out without having set anything up beforehand. i.e. no pre-planned forms like you mention. This is for a current issue, not a future one.
|

October 21st, 2003, 11:25 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
I'm just curious. Your users never exit the db? You couldn't just upgrade the FE, then have everyone get back in using a new FE version? You wouldn't even have to have everyone logged out at once just to do the FE upgrade, would you? Couldn't each user just open the new front-end using a standard version checking routine as they logged back on individually. Just a thought.
Regards,
Bob
|

October 24th, 2003, 02:48 PM
|
Registered User
|
|
Join Date: Sep 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The problem is that, despite NUMEROUS reminders and emails, they lock their computers, leave at the end of the day, and leave the DB open. It's an app that they leave running in the background (holds client contact info). Without fail, even if we try to get everyone out during the day, someone is out of town or something and has left their machine logged into the app.
|

October 24th, 2003, 02:51 PM
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Upgrade the front end with code Bob provided.
Sal
|

July 28th, 2008, 11:52 AM
|
Registered User
|
|
Join Date: Jul 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I also am looking for a way to force an all users exit from an MSAccess2003 database under certain conditions. Any ideas?
Thanks,
Jan
|

August 1st, 2008, 07:14 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
How about another approach? Can you see if there is inactivity for, say, 30 minutes and then have the FE close itself down if so? Then you would have to take NO action yourself. The FE will do it for you automatically.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|

December 1st, 2008, 09:06 AM
|
Authorized User
|
|
Join Date: Jan 2006
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hi,
at a particular time of the day,e:g 7pm daily u can place a code that closes any application that is open.e:g if your application as a start up form,or any other form that u know that the users will ost likely have open whenever they are using the software,then add this code and place it on the form_on current event
private sub form x_(on current)
if time()=19:00 then application.close current database
end sub
|
|
 |