Isolating the fields you want to control is fairly easy; you simply place a
value in the Tag property of each control and then loop thru the controls to
lock/unlock them, based on the Tag property. In Design View you can select
all ten controls, then goto Properties - Other and enter
Protected
***without*** quotation marks.
Then this is the basic code you'll need
Private Sub Form_Current()
Dim ctrl As Control
For Each ctrl In Me.Controls
If (TypeOf ctrl Is TextBox) Or (TypeOf ctrl Is ComboBox) Then
If ctrl.Tag = "Protected" Then
ctrl.Locked = True
End If
End If
Next
End Sub
Private Sub UnLockControls_Click()
Dim ctrl As Control
'Check for password here, if passes Then
For Each ctrl In Me.Controls
If (TypeOf ctrl Is TextBox) Or (TypeOf ctrl Is ComboBox) Then
If ctrl.Tag = "Protected" Then
ctrl.Locked = False
End If
End If
Next
'End If 'Uncomment this line after Password code above is in place
End Sub
This second piece of code above is where you'll put your code for the
password.Now you need to decide what kind of password protection you want,
based on how important this is.
Do you want to hardwire a password in code, then tell only authorized people
the password? This is the simplest, but requires going into the code if you
need to change the password.
Do you want each authorized person to have their own username/password? More
complicated, it requires having a separate table to hold the
usernames/passwords. You then have to compare the username in this table and
check it against the password entered. You also have to make provisions for
entering the usernames/passwords initially.