?
Solved

AllowSpecialKeys setting not applying to current log-in

Posted on 2001-07-10
7
Medium Priority
?
506 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 800 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
Technology Partners: 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

615 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