Tick Box Security

Splity

Registered User.
Local time
Today, 22:43
Joined
May 8, 2001
Messages
16
I am relatively new to the world of Access so forgive me if this is a stupid question.
I want to be able to add some sort of security to a 'YES/NO' field where the user is prompted for a password before being able to update the field.If an incorrect password is entered then the field will not update. The tick box is being used a sign off that only one person out of a number of users is allowed to update.
 
You could set the tick boxes enabled property to no and then put this behind a command button:

Dim strPasswd

strPasswd = InputBox("Enter Password", "Restricted Form")

If strPasswd = "YourPassWord" Then

' Do commands
YourTextBox.Enabled = True

Else

Exit Sub

End If

All you have to do is substitute the generic control names I used with yours and this should do it for you.

If I misunderstood your question or you need more help, just post back to this thread.
 
This solution is EXTREMELY simplistic so I'm not sure you'll want to use it. But it might give you some ideas.

In the General Declarations section of your form (i.e. between Option Declare Database and Option Explicit) declare a constant string variable for your password.
Specifically:
Const conPassword As String = "aardvark"

Then in the Before update event for the field you want to protect add this code, something like:

Private Sub YourFieldName_BeforeUpdate(Cancel As Integer)
Dim strResp As String
strResp = InputBox("You must enter a password to change this field.", "Password", "") 'prompt text, input box title, default value
If strResp = conPassword Then
DoCmd.Save
Else
MsgBox "That password is incorrect."
Cancel = True
End If
End Sub

Note that anyone who has access to the database in design mode can find out what the password is fairly easily. Furthermore, if you use the InputBox function as above, rather than creating a separate form for password entry, your formatting options are pretty limited. That is, you can't format so asterisks are displayed as the user types the password. This is possible however, if you create a separate form.

If you need more details on how to handle this using a separate form, let me know.

P.S. Sorry for posting such a similar response. I must have been typing mine as Talismanic was posting his!
smile.gif


[This message has been edited by RedSkies (edited 05-08-2001).]
 

Users who are viewing this thread

Back
Top Bottom