Passwords on a Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that I would like to password protect. I first created a button
and then created the password input box through VB. The only probelm I had
was, if you hit the cancel button on the Password input box, the input box
wouldn't close. I was looping the code until the correct password was entered
but not sure that's the best way to go about it. What would be the best way
to do this? I would greatly aprreciate it. Thanks!
 
The best way is to apply user level security so that all your users must
sign on when they open your database. Then, you can allow users to have
access only to the objects they need.

Using your method (even if you got it working) what would prevent the user
from simply opening the table and viewing or changing data directly? Or,
what would prevent them from creating a similar form where they could see
all the data?

Assuming you were going to use code to validate the password, what would
prevent them from just viewing the code?
 
Marc:

RBear is absolutely correct, but in case you're in an environment where you
don't actually need real security, and work with people who 1) have no idea
how to view code or even what Access or vba are and 2) don't have the time,
interest, or wherewithal to find out how to do anything in item 1, and your
data isn't security-critical (like credit cards or employee review stats),
you can do the following:

I did this because no one at my job was computer savvy whatsoever, so there
was 0 threat. Again, RBear is right that if you actually need security in
case someone knows what they're doing and also want to bypass the password;
I repeat, this is a workaround for dealing with complete newbs, and probably
isn't even that efficient codewise:

I made a password form with the password input box (form named
frmDesignPass), and in the onclick event of the button "OK" to proceed, I
have this:

If Nz(Me.DesignPass) = "password" Then

Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.Close acForm, "MainMenu"
DoCmd.Close acForm, "frmDesignPass"
stDocName = "frmDesMenu"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Else
MsgBox "Password not correct for Design Department...please try
again", vbOKOnly, "Incorrect Password"
Me.DesignPass = ""
Me.DesignPass.SetFocus
End If

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
Select Case Err.Number
Case 94
Resume Next
Case 2501
DoCmd.OpenForm "MainMenu"
Case Else
MsgBox Err.Number & Err.Description
Resume Exit_Command3_Click
End Select

End Sub

So the password form, which you have open before the form you're trying to
protect, is frmDesignPass. The password in the above example is "password".
The "protected" form is frmDesMenu. I have the swtchboard (MainMenu) open
if they hit "cancel" on the password form instead of inputting a password.
You could also just make an inputbox for the password open in the onopen
event of the "protected" form, but then you need to do a lot of error
handling so the "protected" form doesn't just open when something errors on
the inputbox.

Again, not secure, and again, probably not efficient. I only used it
because no one using my app had any computer knowledge whatsoever, and the
data wasn't really all that significant, we just didn't want the wrong
departments using the wrong forms.
 
Back
Top