Password Request

B

Billy

Im doing a Database, and I created command buttons to open a form, I dont
know if there is a possibilitie to do the following:
When someone click on one of the command button that request a password to
get into the form to add or edit or delete a registry. Is this possible?
Thank You So Much
 
R

Rick Brandt

Billy said:
Im doing a Database, and I created command buttons to open a form, I
dont know if there is a possibilitie to do the following:
When someone click on one of the command button that request a
password to get into the form to add or edit or delete a registry. Is
this possible? Thank You So Much

Rather than putting the password prompt in the button's code, put it into
the Open event of the form. Then it will occur no matter how the form is
opened. Plus, you can open the form from multiple places and don't have to
re-write the password code every time.

In the Open event...

If InputBox("Please Enter Password") <> "YourPassword" Then
MsgBox "Password Incorrect"
Cancel = True
End If

Now, this is rather crude. The password is not masked with asterisks while
being entered. In addition you have to give your users an MDE file or else
they would be free to look at the code and see what the password is. It's
not what I would call "security", but in many cases it accomplishes what you
want.

Another way to go would be to hide everything on the form except for a
TextBox in the middle labeled "Password". In its AfterUpdate you run
similar code except for the Cancel = True part. This allows you to use an
InputMask of "Password" so that the user does see asterisks as he types and
it allows the user to try as many times as he wants rather than immediately
closing the form when the password is wrong. When they get it right, you
hide the password TextBox and display everything else.

If in your case you don't care about viewing, but only editing, you toggle
the AllowAdditions, AllowEdits, and AllowDeletions properties of the form
when the password is entered instead of toggling visibility.
 

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