Solved

AllowSpecialKeys setting not applying to current log-in

Posted on 2001-07-10
7
439 Views
Last Modified: 2012-06-27
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).
0
Comment
Question by:schmir1
7 Comments
 
LVL 6

Expert Comment

by:cjswimmer
ID: 6270865
This setting can only be applied on the next session of Access.  What you can do is determine whether the value was changed by testing with GetOption as follows:

Dim blnCurrent As Boolean
Dim blnCorrect As Boolean
blnCurrent = GetOption("AllowSpecialKeys")
blnCorrect = UserInGroup("Admins")
If blnCurrent <> blnCorrect Then
    ChangeProperty "AllowSpecialKeys", DB_BOOLEAN, blnCorrect
    Shell "msaccess.exe " & CodeDb.Name
    DoCmd.Quit acQuitSaveNone
End If
0
 
LVL 6

Expert Comment

by:cjswimmer
ID: 6270883
just to be safe, you might want to use:

Public Sub RunAtStartup()
On Error GoTo ErrorHandler
    Dim blnCurrent As Boolean
    Dim blnCorrect As Boolean
    blnCurrent = GetOption("AllowSpecialKeys")
    blnCorrect = UserInGroup("Admins")
    If blnCurrent <> blnCorrect Then
        ChangeProperty "AllowSpecialKeys", DB_BOOLEAN, blnCorrect
        Shell "msaccess.exe " & CodeDb.Name
        DoCmd.Quit acQuitSaveNone
    End If
Exit Sub
ErrorHandler:
    Select Case Err.Number
    Case 2091
        blnCurrent = True
        Resume Next
    Case Else
        MsgBox "Error " & Err.Number & vbCrLf & Err.Description
    End Select
End Sub
0
 
LVL 11

Accepted Solution

by:
LambertHeenan earned 200 total points
ID: 6271069
Rather than setting a Db property, I just use a "AutoKeys" macro.

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.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 8

Expert Comment

by:dovholuk
ID: 6271805
BEWARE... beware of autokey macros... the easiest way for me to crack another person's db is by importing the macros that exist, especially the autokeys macro.

it's a real pain that access doesn't "lock down" the macros when creating an MDE file.

so, if you want to be really, really safe, autokey macros aren't going to cut it for you...

but i'm sure a macro has the ability to do what you want...

kindof a catch 22.

dovholuk
0
 

Author Comment

by:schmir1
ID: 6273254
Very easy solution to implement and test.  Shouldn't impact startup time either.  I appreciate the other comments offered and may go that route in the future.  I also understand the my database security could be breeched.  Currently, all my users are fellow employees and they are very unlikely to try to do something bad to the data.  I'm just looking to prevent accidental mistakes.

Thanks everyone,
>>> Bob <<<
0
 
LVL 11

Expert Comment

by:LambertHeenan
ID: 6273608
Of course if your Db is already _secured_ (as it appears to be, why else would you be checking if the current user is in the group "Admins") then you can remove all permissions from all your macros except "Open/Run".

Then your ordinary user will not be able to import/export the macros to anther database so they cannot modify it.

If the databse IS NOT secured, then yes, you can do what you like with the macros by importing them to another Db, messing with them and then exporting them back to the original MDE file.
0
 
LVL 11

Expert Comment

by:LambertHeenan
ID: 6273619
PS

I mean (of course) to remove all persmissions except Open/Run for all user groups except Admins
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now