I am looking for the code to disable special keys in VBA.
I know that you can use the startup option however i want to allow special key use for specific people.
I'm not 100% sure of this but I think if you change this setting programmatically you will have to close the database and re-open again for it to be effective.
The code below will allow you to set the Startup properties.
The property has to be created before it can be set, but it can be set as it is created (if you see what i mean).
But as I said before you have to close the file and re-open for a change to take effect.
Usage:
CreateProps 3
The final 0 for each statement can be 0 or 1 depending on whether you are unsetting or setting the option.
Sub createprops(x)
Dim prp As DAO.Property
Dim db As Database
Set db = CurrentDb()
Select Case x
Case 1
Set prp = db.CreateProperty("StartUpShowDBWindow", 1, 0)
db.Properties.Append prp
Case 2
Set prp = db.CreateProperty("AllowBreakIntoCode", 1, 0)
db.Properties.Append prp
Case 3
Set prp = db.CreateProperty("AllowSpecialKeys", 1, 0)
db.Properties.Append prp
Case 4
Set prp = db.CreateProperty("AllowToolbarChanges", 1, 0)
db.Properties.Append prp
Case 5
Set prp = db.CreateProperty("AllowFullMenus", 1, 0)
db.Properties.Append prp
Case 6
Set prp = db.CreateProperty("AllowBuiltInToolbars", 1, 0)
db.Properties.Append prp
Case 7
Set prp = db.CreateProperty("AllowByPassKey", 1, 0)
db.Properties.Append prp
Case Else
'do nothing
End Select
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.