KillSwitchEngage Access VBA Code

ClearlyDarkly

New Member
Joined
Apr 20, 2016
Messages
1
Hello

Long time lurker, New Member, i just wanted to show you my KillSwitchCode for use with a New Split/End MultiUser Access Database, I have been coding for less that half a year (trying to get onto a training course) and just wanted to hear your opinions and concerns regarding using it.

Kill Switch Code
The Idea of this code is to give a 2 minute warning to employees that they need to come out of the Database and that it will auto close if they stay in it (Compact & Repairing), Also have AutoBots doing stuff on webpages (Selenium Wrapper) and using a emulator for automation purposes.

The Code comes in 4x Parts and 1x Table.

---> This is on a 1 Minute Timer to check if a Tick Box is Ticked in Tbl_KillSwitchEngage, Form needs to be loaded but can be hidden, This is a Logon Form
Code:
Private Sub Form_Timer()
Dim KillSwitchRST As DAo.Recordset


Set KillSwitchRST = CurrentDb.OpenRecordset("Select * FROM Tbl_KillSwitchEngage")


If KillSwitchRST.RecordCount > 0 Then


    DoCmd.OpenForm "Frm_KillSwitchEngage", acNormal, , , , acWindowNormal


End If


KillSwitchRST.Close
Set KillSwitchRST = Nothing


End Sub

---> This is a Button that Ticks the Tick box in Tbl_KillSwitchEngage
Code:
Private Sub KillSwitchEngage_Click()Dim KillSwitchRST As DAo.Recordset
Dim InputPassword As String
Dim PasswordCheck As String


InputPassword = "Choose a Password"


PasswordCheck = InputBox("Please enter the password to run this command", "Password Required")


If InputPassword = PasswordCheck Then


    Set KillSwitchRST = CurrentDb.OpenRecordset("Select * FROM Tbl_KillSwitchEngage")
    
    KillSwitchRST.AddNew
    KillSwitchRST!EngageKillSwitch = True
    KillSwitchRST.Update
    
    KillSwitchRST.Close
    Set KillSwitchRST = Nothing


Else


    MsgBox "The password you have entered is incorrect, Please retry or contact the system administrator"


End If

End Sub

---> This is a Warning Form with a Timer on for 2 Minutes, once 2 minutes reached, Database will Close, Won't Close but can be hidden.
Code:
Private Sub Form_Timer()

DoCmd.Quit

End Sub

---> This is the OK Button to hide the Warning Form
Code:
Private Sub OKButton_Click()

Form_Frm_KillSwitchEngage.Visible = False

End Sub

My concerns are:
1. The Database will not close cleanly causing a corruption,
2. In order to stop the database from initiating the kill-switch you have to delete the record out of the Tbl_KillSwitch, this to also change
3. InputPassword is "HardCoded" this will change.
4. Shift Clickers won't get the popup as the Login Form won't Load.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,221,819
Messages
6,162,155
Members
451,749
Latest member
zack_ken

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top