Remote shutdown of a shared DB...

There is code that you can use to call a message box that will disapear after x number of seconds. I use the below code to do just that when I give the users a warning message that the application will shut down in 30 seconds. If the user clicks the OK button then the db shuts down right away, otherwise the message box will auto close in 30 seconds and then the db will shut down. It is nice to at least warn the users in the db with a message since you do not know which form they are in.

'Put this at the top of a public module [not a form module]
Code:
'Used with a timed message box
Public Property Get oMsgBox() As Object
    Set oMsgBox = CreateObject("WScript.Shell")
End Property
'Put this in your routine to force close the application
Code:
[COLOR=green]    'oMsgBox.PopUp "Testing...closing in ten seconds.", [COLOR=blue]10[/COLOR], "Force Closed", vbInformation[/COLOR]
    oMsgBox.PopUp "Your copy of the XXXX program will be closed in thirty seconds.  The data tables in the XXXX program are being updated or the XXXX program is being taken off line for maintenance.  You may try to open the XXXX program again in twenty minutes." & vbCrLf & vbLf & "Please contact XXXX if you continue to have problems opening the XXXX program.", 30, "Force Closed", vbInformation
    DoCmd.RunCommand acCmdExit

Hi ghudson,

thank you for this code, this code working for me except the force close
'oMsgBox.PopUp "Testing...closing in ten seconds.", 10, "Force Closed", vbInformation
oMsgBox.PopUp "Your copy of the XXXX program will be closed in thirty seconds. The data tables in the XXXX program are being updated or the XXXX program is being taken off line for maintenance. You may try to open the XXXX program again in twenty minutes." & vbCrLf & vbLf & "Please contact XXXX if you continue to have problems opening the XXXX program.", 30, "Force Closed", vbInformation
DoCmd.RunCommand acCmdExit
i was not clear when you routine, where should i exactly use this
 
'Put this in your routine to force close the application
Code:
[COLOR=green]    'oMsgBox.PopUp "Testing...closing in ten seconds.", [COLOR=blue]10[/COLOR], "Force Closed", vbInformation[/COLOR]
    oMsgBox.PopUp "Your copy of the XXXX program will be closed in thirty seconds.  The data tables in the XXXX program are being updated or the XXXX program is being taken off line for maintenance.  You may try to open the XXXX program again in twenty minutes." & vbCrLf & vbLf & "Please contact XXXX if you continue to have problems opening the XXXX program.", 30, "Force Closed", vbInformation
    DoCmd.RunCommand acCmdExit
[/QUOTE]

Hello ghudson,

many thanks for this wonderful post, I used both of your codes and I get the pop up message but its not force closing after 30 seconds
any help? or suggestions ? :banghead:
 
Hi Guys,
I have an ask over here. How to shut down a custom Access application remotely with Timer on the form which will pop up to the user.
As we may have to perform maintenance tasks on a Microsoft Access database, such as compacting or repairing, making backup copies, or making design modifications. Many of these operations require that all users exit the database. However, there is no built-in way to force users to quit Microsoft Access. Your input is highly appreciated.

Rgds,
Akbar Alam
 
I have a backend table called tblKickout with a boolean field Kickout.
The value of that field is monitored every 30 seconds.
When maintenance is required, the program admin sets Kickout = True and this starts a countdown procedure to forcibly close the frontends of all users of the application. I use a countdown time of 5 minutes but this can be altered.

As explained earlier in this thread by other members, I also use an idle time check to close apps where no activity has been detected in say 20 minutes.

Here's a link to a more recent thread with my solution and an example app so you can try it out

https://www.access-programmers.co.uk/forums/showpost.php?p=1546375&postcount=13
 

Users who are viewing this thread

Back
Top Bottom