Share via

Locking/Unlocking database forms

Anonymous
2016-02-21T20:02:34+00:00

i want to add a button to my access database that will allow my database forms to be unlocked until either the button is clicked again for the database is saved and closed. This will unlock all forms in the database 

The database will open with forms being locked. 

Thank you.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

6 answers

Sort by: Most helpful
  1. Anonymous
    2016-02-23T23:48:15+00:00

    Thanks for the check box advice. I am struggling to implement it correctly the coding is as you have put it on here. But it does not lock any of the forms from editing.

    Was this answer helpful?

    0 comments No comments
  2. ScottGem 68,830 Reputation points Volunteer Moderator
    2016-02-22T00:03:28+00:00

    Sure. First let me suggest that you review my blog article on Login Security with VBA. It discusses techniques to secure your database.

    A simple way to do this would be to use the Before Update event of the check box.

    Dim strPW AS String

    strPW = InputBox("Enter password to unlock forms?", "Unlock forms")

    If strPW <> "password" then

         Cancel = True

         MsgBox "You are not authorized to unlock forms!"

    End If

    However, it would be very easy for someone to get past this. A more secure way would be to add a login to the app and not even show the checkbox to those not authorized.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2016-02-21T22:51:41+00:00

    Thank you for the advice would I be able to go one step further by adding a password when the user tries to unlock the forms ? 

    If possible how would I implement that ? 

    Many thanks

    Was this answer helpful?

    0 comments No comments
  4. ScottGem 68,830 Reputation points Volunteer Moderator
    2016-02-21T22:28:10+00:00

    Add a single record parameters table to your database. include a Yes/No field named UnLocked. 

    In your main form, add a subform bound to this table with a checkbox control for that field. 

    In the On Load event for each of your forms add the code:

    Me.AllowEdits = DLookup("[Unlocked]","tblParameters")

    Me.AllowAdditions = DLookup("[Unlocked]","tblParameters")

    Me.AllowDeletes = DLookup("[Unlocked]","tblParameters")

    When each form opens it will set those properties to the value of the Unlocked field. So if Unlocked is True, then those properties will be set to True, if its False then those properties would be set to False.

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2016-02-21T21:13:18+00:00

    ciao Shaunellis,

    you could work on recordsetType or looping through your control locking them,

    the former is the easiest way in my opinion.

    have a look at here :  http://1drv.ms/1mRiMZy lock.accdb.

    Ciao, Sandro.

    Was this answer helpful?

    0 comments No comments