Interactive Password Login on a Form

G

Guest

I have MS Access 2003 and I have created a form as a start page for my
database. On that form, I have added a textbox with the word "Password' in
it, and I have added a field next to that in which someone could type a
password. Does anyone know how I could set a password for someone to login
to my form? I am talking about an interactive login to the form, not the
database itself.

Basically, I made a form, and I put a command box on it labeled password...
I want to be able to put my password in the box and hit the enter button and
be able to access my database.

Please advise, thank you.
 
R

Rick Brandt

Amanda George said:
I have MS Access 2003 and I have created a form as a start page for my
database. On that form, I have added a textbox with the word "Password' in
it, and I have added a field next to that in which someone could type a
password. Does anyone know how I could set a password for someone to login
to my form? I am talking about an interactive login to the form, not the
database itself.

Basically, I made a form, and I put a command box on it labeled password...
I want to be able to put my password in the box and hit the enter button and
be able to access my database.

Please advise, thank you.

First off you should know that this sort of "security" will be trivially
easy to circumvent for anyone with even a smattering of knowledge of how
Access works. So unless you are just providing guidance without really
expecting to keep out evil-doers then don't waste your time. Even though
it can be hacked the built in User Level security will be light-years ahead
of anything you can cook up yourself, but it does have a steep learning
curve.

Now...to your question.

You would basically use the AfterUpdate event of the password TextBox to
run code like...

If Me.PasswordBox = "MyPassword" Then
DoCmd.OpenForm "MySwitchboard"
Else
MsgBox "Incorrect Password"
End If

Now you can see that if you don't distribute an MDE or use security to
prevent going into design view that anyone will be able to examine this
code and see what the password is. If it is the data you are protecting
this system will not prevent anyone from examining the tables directly or
even importing them into another file and looking at the data that way.
 
R

Rick B

Don't. Access has built-in user-level security, or database passwords. Why
reinvent the wheel?

Also, this would be very easy to get around.

Rick B
 
G

Guest

Is this code below actual VBScript? Where would I inside this code in the
form?

If Me.PasswordBox = "MyPassword" Then
DoCmd.OpenForm "MySwitchboard"
Else
MsgBox "Incorrect Password"
End If
 
R

Rick Brandt

Amanda George said:
Is this code below actual VBScript? Where would I inside this code in the
form?

If Me.PasswordBox = "MyPassword" Then
DoCmd.OpenForm "MySwitchboard"
Else
MsgBox "Incorrect Password"
End If

Access doesn't use VBScript. It uses VBA.

You would presumably have a Command Button that the user would press after
entering their password. You would use the Click event of that button to
run the code. You could alternatively use the AfterUpdate event of the
Password control itself.
 

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

Similar Threads


Top