Solved

AllowSpecialKeys setting not applying to current log-in

Posted on 2001-07-10
7
479 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

696 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