Results 1 to 3 of 3
  1. #1
    robbeh is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    55

    Question Create Property for AllowBypassKey

    I am try to lockup my database to certain user levels using a custom security.

    Essentially if they are a certain user level I want to disable as many ways to make changes as possible.

    I have a database here that I am trying to base the example off of. My question is, how do I use the create property? I don't understand this line:

    "In a Microsoft Access database (.mdb or .accdb), you can add the property by using the CreateProperty method and then appending it to the Properties collection of the Database object."



    How do I do that?

    Then I plan to use:

    With dbThis
    .Properties("AllowBypassKey") = bUnLocked
    .Properties("AllowShortcutMenus") = bUnLocked
    .Properties("AllowFullMenus") = bUnLocked
    .Properties("AllowBuiltInToolbars") = bUnLocked
    .Properties("AllowToolbarChanges") = bUnLocked
    .Properties("AllowBreakIntoCode") = bUnLocked
    .Properties("AllowSpecialKeys") = bUnLocked
    End With

    where bUnLocked would be a T/F based on user level.

    I am newer to Access but slowly starting to really get my teeth sunk in.

  2. #2
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119
    Though I've never locked up a database like this (I usually just compile as an ACCDE and that prevents users from doing design changes), here's what I do know.
    To write code for this, there are a few things to note:

    1. Some of these settings you want to change at runtime may not change at that runtime. Options like AllowFullMenus, ShortcutMenus, etc. usually require a restart of the DB to take effect.
    2. If you want to try like this anyway, you will need to first test if the property exists. If so, then just set like you do above. However, if the property doesn't exist, you will need to add it to the Properties collection. First you would need to create a Property, and then use the Database.Properties.Append method to add it, then set it. See if this article helps: http://accessdatabasetutorial.com/20...es-properties/

  3. #3
    robbeh is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2014
    Posts
    55
    Thanks thebigthing313,

    The reason I am doing it this way is the database needs to be developed for 2003-2013 users since the organization here is spread across the board. It's a customish security I have created. Uses a table in the DB to store privileges that's hidden. I then check privileges when the database opens and adjust items based on user level.

    I then have a separate database that links to the permissions table - this is like the key. If you have admin privileges you can see a management menu where you can toggle the database lock on and off.

    Not ideal but I am hoping it gets the job done.

    For those of you with the same problem I had, to set the property:
    Code:
    Function CreateProperty(PropName As String, dbType As Variant, PropValue As Variant)
        Dim DB As Database
        Dim P As Property
        
        Set DB = DBEngine(0)(0)
        Set P = DB.CreateProperty(PropName, dbType, PropValue)
        DB.Properties.Append P
        
    End Function
    
    Sub RunCreateProperty()
        CreateProperty "AllowBypassKey", dbBoolean, True
    End Sub
    I just created a module, you can manually run the CreateProperty code by placing your cursor in the Sub and clicking Run. You could also append it to a button or however you like. I set it to True as that's the default.

    To toggle it add this code to a button etc:

    Code:
    Public dbThis As DAO.Database 'Declared in a modGlobal module
    dbThis.Properties("AllowBypassKey") = False
    Thank you for the help and hopefully that helps others.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 04-04-2014, 03:33 PM
  2. Replies: 7
    Last Post: 01-16-2014, 09:17 AM
  3. Replies: 1
    Last Post: 05-20-2013, 01:45 PM
  4. How to use "Securing AllowBypassKey" code
    By ped in forum Programming
    Replies: 0
    Last Post: 12-30-2011, 01:45 PM
  5. Create Property
    By RAPSR in forum Programming
    Replies: 2
    Last Post: 10-12-2010, 12:39 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums