Display Form to select the form you created. This means that when the database is loaded it
will automatically default to your new form.
On the form, you need to view it in Design mode and right-click it to select properties.
Select Form in the Selection Type drop-down. You need to set the Ribbon Name property to
MyRibbon or whatever you called the custom ribbon.
One further problem exists. All this code and XML will lock the database up completely.
At some point, you will need to do maintenance on the database, so how do you get back in?
Currently there is no way to get back in to change anything. What you need is a “back
door” that users are unlikely to discover but which will let you in.
Right-click the form you created and select Properties. Choose Form properties on the
drop-down and navigate to Key Preview. Set this property to Yes and save the form. This
means that keypresses on the form can be picked up by your code.
Return to the module you created and add the following procedure:
Sub EnableStartupProperties()
ChangeProperty "StartupShowDBWindow", dbBoolean, True
ChangeProperty "StartupShowStatusBar", dbBoolean, True
ChangeProperty "AllowBuiltinToolbars", dbBoolean, True
ChangeProperty "AllowFullMenus", dbBoolean, True
ChangeProperty "AllowBreakIntoCode", dbBoolean, True
ChangeProperty "AllowSpecialKeys", dbBoolean, True
ChangeProperty "AllowBypassKey", dbBoolean, True
ChangeProperty "AllowShortcutMenus", dbBoolean, True
End Sub
On the form you created, add the following code to the module for that form:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 191 And Shift = 1 Then
EnableStartupProperties
MsgBox "Security Disabled", vbInformation
End If
End Sub
In this code, 191 is the ASCII code for a question mark (?). Because it is on the Key Down
event for the form, all you need to do is click the form itself and then pressSHIFT+?. A message
will appear saying security has been disabled. Close the database and load it for the changes
to take effect. You will also need to use the File tab to change the ribbon back to the Access
default.
You should not use this special key on the live version when doing maintenance, since that
will leave it open to everyone. Instead, take a copy and disable the security on the copy. Then
make your changes on the copy, which will then replace the live version of the database. This
will maintain the data that has been entered.
If you close the database and then reload it, the screen should look like Figure 24-1.
286 Microsoft Access 2010 VBA Macro Programming