Paul Barrett
asked on
Trigger code in Access db that is locked, to unlock it
I have made a bit of a development faux pas!
Prior to releasing my access 2007 db to the end users I always run code that locks it (no bypass key) and does some other stuff.
I went to site, unlocked the db (I have a hidden button on a welcome form that does this, but only available when user logs on and form presented). I made some changes, relocked, put on my usb stick, bought back to my office, went to open it forgetting that there would be an ODBC error re different SQL instance. Office is 50 miles away so would rather not go back just to get an unlocked one!
As I cannot open it I cannot get to the form that has hidden button to run unlock code.
Can I fire the code from outside that db so it will perform the code on that db?
Code:
Public Sub SetBypassProperty()
Const DB_Boolean As Long = 1
Application.SetOption "ShowWindowsInTaskbar", False
ChangeProperty "StartupShowDBWindow", DB_Boolean, False
ChangeProperty "StartupShowStatusBar", DB_Boolean, False
ChangeProperty "AllowBuiltinToolbars", DB_Boolean, False
ChangeProperty "AllowFullMenus", DB_Boolean, False
ChangeProperty "AllowBreakIntoCode", DB_Boolean, False
ChangeProperty "AllowSpecialKeys", DB_Boolean, False
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName ) = varPropValue
ChangeProperty = True
Change_Bye:
Exit Function
Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strProp Name, _
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
Prior to releasing my access 2007 db to the end users I always run code that locks it (no bypass key) and does some other stuff.
I went to site, unlocked the db (I have a hidden button on a welcome form that does this, but only available when user logs on and form presented). I made some changes, relocked, put on my usb stick, bought back to my office, went to open it forgetting that there would be an ODBC error re different SQL instance. Office is 50 miles away so would rather not go back just to get an unlocked one!
As I cannot open it I cannot get to the form that has hidden button to run unlock code.
Can I fire the code from outside that db so it will perform the code on that db?
Code:
Public Sub SetBypassProperty()
Const DB_Boolean As Long = 1
Application.SetOption "ShowWindowsInTaskbar", False
ChangeProperty "StartupShowDBWindow", DB_Boolean, False
ChangeProperty "StartupShowStatusBar", DB_Boolean, False
ChangeProperty "AllowBuiltinToolbars", DB_Boolean, False
ChangeProperty "AllowFullMenus", DB_Boolean, False
ChangeProperty "AllowBreakIntoCode", DB_Boolean, False
ChangeProperty "AllowSpecialKeys", DB_Boolean, False
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub
Function ChangeProperty(strPropName
Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName
ChangeProperty = True
Change_Bye:
Exit Function
Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strProp
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER