Password Protect a Form

G

Guest

I have a database and I would like to password protect a form.
I have created a table called tblpassword with two fields
user (primary key)
password
Then I created a from that will open when you click on the switchboard
button for this form it pops up requesting the user name and password.
Both unbounded text boxes named User and Password respectivly.
I then have a command button that is to run a macro if the user name and
password are corret...here is the code I put in at the on click for the
command button. (Run-time error '3078') so I do the debug and it highlights
the line in code reading...
If Me.Password = DLookup("[Password]", "tlbpassword", "[User]='" & Me.User &
"'") Then

Any idea...I know this is not the best for security however this is how the
higher powers want it.

Private Sub Command8_Click()
If Me.Password = DLookup("[Password]", "tlbpassword", "[User]='" & Me.User
& "'") Then
DoCmd.RunMacro (OpenForm)
Else
MsgBox "Invalid password"
End If

End Sub

I then put a few test User and Passwords in the table however I get an error
when I click the button...
 
R

Rick B

Why are you going through all that? Access has a built-in method of storing
userid's and passwords. They will even be encrypted so your user's can't
simply go look at your table and get the passwords from there.

You should put User-Level Security in place and not try to reinvent the
wheel. Once you do, you will be able to limit access to all the objects in
your database with just one simple login when the file is opened.

I'd recommend making a backup or two and then reading the following very
carefully. Skipping any steps, or going out of order will cause problems,
so follow the instructions closely...

Security FAQ

http://support.microsoft.com/?id=207793



The Security Whitepaper is also worth reading to help you understand.

http://support.microsoft.com/?id=148555



Joan Wild:

www.jmwild.com/AccessSecurity.htm



Lynn Trapp

http://www.ltcomputerdesigns.com/Security.htm
 
R

Rick B

FYI: I just reread you post and noticed the "higher power" part. You may
want to point out that as the developer, their desired method is not
something you'd recommend. You may want to point out the loopholes, and the
maintenance issues. Nothing you do in Access is going to be very secure,
but using your method really does nothing to keep out a person that has any
real knowledge of Access. Anyone that has built a database from scratch
will probably be able to get into your table or your code. The only ones
you are really keeping secure are the higher power people you mention that
might not know anything about Access.
 

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