Password Prompt to Edit Form

J

Janna

I've used Allen Browne's Locking bound control codes
(http://allenbrowne.com/ser-56.html) to prevent overwriting data accidentally
within an Access form and it works perfectly.

Now, to make it slighly more difficult for certain users to edit this form,
I'd like to add code behind the cmdLock command button (code below) to prompt
for a password to unlock the form. I realize this isn't strong security. I
just want to make it a little more challenging for certain staff to be able
to edit the form when they should have read-only permission.

Private Sub cmdLock_Click()
Dim bLock As Boolean
bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)
Call LockBoundControls(Me, bLock)
End Sub
 
D

Dale Fye

The simplist method would be to popup an inputbox asking for the password.
Also, when I do this sort of thing, I like to change the caption on the
comand button.

Something like:

Private Sub cmdLock_Click()

Dim bLock As Boolean

if Inputbox("Enter password!") <> "password" Then Exit Sub

bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)
me.cmdLock.Caption = IIF(bLock = True, "&UnLock", "&Lock")

Call LockBoundControls(Me, bLock)

End Sub

To get a little more restrictive, you could add a permissions table
(tbl_Form_Permissions) to the database, and assign individuals specific
permissions to a given form (store the form name, userid, and permissions
"ReadOnly", "Update", "Add", "Delete", ...). Then you could query the form
to determine whether the user has the appropriate permission before allowing
them to perform a specific function on that form.

Even more complicated, when the user opens the form, you could
enable/disable or hide certain functions or buttons, so they don't even have
the option to use that functionality on the form. This can get pretty
complicated, pretty quickly. And requires you to maintain the permissions
table.
--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top