Consulting

Results 1 to 3 of 3

Thread: Password Protecting records

  1. #1
    VBAX Newbie
    Joined
    Jan 2005
    Posts
    1
    Location

    Password Protecting records

    I am working on a project in Access 2000 using DAO. I have a record locked on a form and I was curious if there is a way to set a password on the record so that the locked property could be set to false if the correct password was entered. Any advice would be appreciated.

    Thanks in advance!

  2. #2
    VBAX Tutor SJ McAbney's Avatar
    Joined
    May 2004
    Location
    Glasgow
    Posts
    243
    Location
    If each record is to have a password then why not add a password field.

    In the form's OnCurrent event, you can test if the record has a password and if not allow the fields to be edited otherwise cycle through the controls and locking them.

    i.e

    [vba]
    Private Sub Form_Current()
    LockControls IsNull(Me.txtPassword)
    End Sub

    Private Sub LockControls(ByVal Lock As Boolean)
    On Error Resume Next
    Dim ctl As Control
    For Each ctl In Me.Controls
    ctl.Enabled = Lock
    ctl.Locked = Not Lock
    Next
    Set ctl = Nothing
    End Sub[/vba]

    You wouldn't need a DAO solution.

  3. #3
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    I invited someone to join our forum here. He's declined due to other commitments, but did email me these comments, and then indicated that I could post them here:

    BTW, one question on your site related to password protecting individual records outside of the locking mechanism created by Access. As I read it, this is not possible. A "password field" scheme, as suggested by the responding member, would work for protecting the data as a whole, but Access itself determines when and where to put a lock on a record, and its decision in this regard is inviolate. In other words, if Access locks a record, the only way to remove the lock is to update the record, or undo changes. The user could change their locking strategy to "No Locks", or MAYBE "Optimistic Locking", but those strategies risk data integrity, and I would not suggest that course of action.
    Please don't ask me anything, 'cause I have NO idea what he's talking about! LOL!
    ~Anne Troy

Posting Permissions

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