View Full Version : Password Protecting records

01-06-2005, 04:23 PM
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!

SJ McAbney
01-08-2005, 12:59 PM
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.


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
Set ctl = Nothing
End Sub

You wouldn't need a DAO solution.

Anne Troy
02-16-2005, 02:46 PM
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!