Solved

AllowSpecialKeys setting not applying to current log-in

Posted on 2001-07-10
7
459 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 importing text files 13 20
Access 2016 - query 23 59
Exporting Access Tables as CSV 3 23
DCount Type Mismatch 2 21
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…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 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