Results 1 to 10 of 10
  1. #1
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10

    Thumbs down Unanswered: Unlocking Access Database

    I know similar threads have appeared here before but none of them answer what I want to do

    I have a Access 2003 database which I have locked, turned off access special keys and disabled the SHIFT bypass. I have implimented the following code behind a button only the administrators can see:

    Private Sub cmdGOD_Click()

    Call ChangeProperty("StartupShowDBWindow", DB_BOOLEAN, True)
    Call ChangeProperty("StartupShowStatusBar", DB_BOOLEAN, True)
    Call ChangeProperty("AllowBuiltinToolbars", DB_BOOLEAN, True)
    Call ChangeProperty("AllowFullMenus", DB_BOOLEAN, True)
    Call ChangeProperty("AllowBreakIntoCode", DB_BOOLEAN, True)
    Call ChangeProperty("AllowSpecialKeys", DB_BOOLEAN, True)
    Call ChangeProperty("AllowBypassKey", DB_BOOLEAN, True)
    Call ChangeProperty("AllowShortcutMenus", DB_BOOLEAN, True)
    Call ChangeProperty("AllowToolbarChanges", DB_BOOLEAN, True)

    End Sub


    This procedure calls the following function:

    Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer

    On Error GoTo ChangeProperty_Err

    Dim dbs As Object
    Dim prp As Variant
    Const PropertyNotFoundError = 3270

    Set dbs = CurrentDb
    On Error GoTo ChangeProperty_Err
    dbs.Properties(strPropName) = varPropValue
    ChangeProperty = True

    ChangeProperty_Exit:

    Err = 0
    On Error GoTo 0
    Exit Function

    ChangeProperty_Err:

    If Err = PropertyNotFoundError Then ' Property not found.
    Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
    dbs.Properties.Append prp
    Resume Next
    Else

    Resume ChangeProperty_Exit
    End If

    End Function


    Basically, this will only run on the next startup.
    I want the code to run as soon as the button is pressed for security reasons.
    I have tried my hardest to find some sort of database refresh (currentDB.refresh etc) but with no luck!

    OR

    Is there another way I can lock the database for everyone except one user?
    This is what I'm trying to do above with no luck so far!

    Thank you in advance for any help you can give me!

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    A simpler approach might be to have a form that fires up with visible set to false that periodically checks a table in your database to determine what user mode it should be running in.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10

    Thumbs up

    Unfortunately, this is not my system, just one I am helping to "make secure" therefore I am not able to play about with tables as I would like.

    Can you elaborate on what you mean by "visible set to false" please?
    If I understand correctly, I already have the button implemented for the one user only, based on their username.

    The problem is, when I run this code, I have to exit, then re-launch the database for the property changes to take effect. This means that when it is unlocked, the next person (regardless of username etc) can access everything.

    I just need to refresh the properties/apply the changes without having to close the database.

    Cheers
    Last edited by gvee; 01-03-07 at 12:26.

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    If needs be I can upload the *.mdb file on request for all to see (and play with) (and fix it)

  5. #5
    Join Date
    Mar 2004
    Location
    UK
    Posts
    82
    you say that the code only runs when the db is restarted?

    the code is run when the command button is clicked but the properties you are changing are "startup" properties so the effect of them being changed from false to true will not be apparent until the db is "started up" again,

    according to microsoft knowledge base you HAVE TO restart the db app.

    the simple way around this might be to give the user who you want to have special privilages a seperate password protected ffont end db that is linked to the same backend db.

    your administrator will have access the all required data etc, while users will use a different front end that has resricted access.
    Last edited by "L"PLATE; 01-03-07 at 15:42.

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by georgev
    Private Sub cmdGOD_Click()

    Call ChangeProperty("StartupShowDBWindow", DB_BOOLEAN, True)
    Call ChangeProperty("StartupShowStatusBar", DB_BOOLEAN, True)
    Call ChangeProperty("AllowBuiltinToolbars", DB_BOOLEAN, True)
    Call ChangeProperty("AllowFullMenus", DB_BOOLEAN, True)
    Call ChangeProperty("AllowBreakIntoCode", DB_BOOLEAN, True)
    Call ChangeProperty("AllowSpecialKeys", DB_BOOLEAN, True)
    Call ChangeProperty("AllowBypassKey", DB_BOOLEAN, True)
    Call ChangeProperty("AllowShortcutMenus", DB_BOOLEAN, True)
    Call ChangeProperty("AllowToolbarChanges", DB_BOOLEAN, True)

    End Sub
    Is there anyway that the "Allow..." properties can be run without a restart of the db?
    Last edited by gvee; 01-04-07 at 04:50.

  7. #7
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Talking

    Good afternoon and Happy New Year to everyone. Why not use Access security for setting passwords and then in your code set it where only certain login/usernames are allowed to access certain data. Either make those Forms etc. Visible to that user or AllowEdits to that user. Just something to think about.

    have a nice one,
    BUD

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Good suggestion bud, I will talk it over with my colleague.

    However, this is an existing system we are developing/making secure.
    It has coded user access levels that exist already, so I was trying to come up with a way of coding in a new security level in the same way as already exists in the database.

  9. #9
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Sorry for bumping the topic but I'm still looking for an answer

    Question:
    Is there any way I can refresh the startup properties for a database?

    Example
    Code:
    Call ChangeProperty("AllowBypassKey", DB_BOOLEAN, True)
    Call ChangeProperty("AllowShortcutMenus", DB_BOOLEAN, True)
    Call ChangeProperty("AllowToolbarChanges", DB_BOOLEAN, True)
    These only refresh on startup and I want to unlock the database by clicking a button only available to certain users.

    Cheers
    George

  10. #10
    Join Date
    Mar 2004
    Location
    UK
    Posts
    82
    you could get by your problem by having the db open by default with the special keys etc enabled. then using the onload event of your startup form, remove the desired menus, hide the db window and anything else. then you can give access to the desired functions depending on the user.

    not an ideal way and i wouldn't be happy about users having access to the bypasskey.

    if you can let me see a sample of your app i'll see if i can get anywhere with it in spare time

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •