I'm trying to disable users from bringing up the database window unless they are in the Admins group. I used the following code which runs when the startup Switchboard form's On Open event runs:
If UserInGroup("Admins") Then
ChangeProperty "AllowSpecialKeys", DB_Boolean, True
Else
ChangeProperty "AllowSpecialKeys", DB_Boolean, False
End If
It runs and does set the AllowSpecialKeys properties (as observed from the Startup dialog box). Unfortunately, the setting doesn't take effect until the next time the database is opened. So if a Admins person logs in on the same PC after Non-Admins person then the Admins person isn't able to open the database window (and he should be able to). Now if he just quit then the next person to use this PC will be able to bring up the database window no matter what group he is in.
Anyone know how to make the setting apply as soon as the person logs in. I know if I run the compact utility then the AllowSpecialKeys setting takes effect but that will slow down the start up process (and I'm not sure I know how to do it with code).
The macro uses three columns
1/ Macro Name -- {F11} (The 'special key' to display the db window)
2/ Condition -- UserInGroup("Admins") (Function returns true or false)
3/ Action -- Run Code - function named ShowDbWindow()
The ShowDbWindow functon looks like this (in Acccess 97)
Function ShowDbWindow()
DoCmd.SelectObject acTable, , True
End Function
So if the current user is in the Admins group the ShowDbWindow function runs, otherwise nothing happens when the user hits F11.