IF then / Password

G

Guest

I have a form that has a password text box (Password_txt). I want it to look at a field in a table or another text box (ExtraPassword_txt) in the form that is populated by a table or query and verify the password before opening a different form.

Now I have a if then statement that looks to make sure a password is typed in before it opens the form. I tried to get it to work by looking at a field in a table, or form but it doesn't work.


Here is the code for the one that works with everything (encluding the password) in the code.

If Me![Password_txt].Value = "password" Then
DoCmd.Close , , acSaveNo
DoCmd.OpenForm "BlueSheetExtras"
DoCmd.OpenForm "BlueSheet"
ElseIf IsNull(Forms![Password]![Password_txt].Value) Then
MsgBox "Invalid Password"
Forms![Password]![Password_txt].Value = ""
ElseIf Not Me![Password_txt].Value = "Password" Then
MsgBox "Invalid Password"
Forms![Password]![Password_txt].Value = ""
End If

This one doesn't work unless the ExtraPassword_txt is visible and you click on the ExtraPassword_txt after entering in the password on the Password_txt text box. I don't want the password_txt visible though. The password_txt is linked to a table field (also tried a query) that has the password in it. Is they anyother way to get this to work?

If Me![Password_txt].Value = Me![ExtraPassword_txt].Value Then
DoCmd.Close , , acSaveNo
DoCmd.OpenForm "BlueSheetExtras"
DoCmd.OpenForm "BlueSheet"
ElseIf IsNull(Forms![Password]![Password_txt].Value) Then
MsgBox "Invalid Password"
Forms![Password]![Password_txt].Value = ""
ElseIf Not Me![Password_txt].Value = Me![ExtraPassword_txt].Value Then
MsgBox "Invalid Password"
Forms![Password]![Password_txt].Value = ""
End If
 
D

Daniel Carollo

Hello BN!

Try getting your password from the table using the DLookup() function.

Hope that helps...

--
Daniel :)

Computing Technologies International - www.computing-tech.com - We
provide solutions...

BN said:
I have a form that has a password text box (Password_txt). I want it to
look at a field in a table or another text box (ExtraPassword_txt) in the
form that is populated by a table or query and verify the password before
opening a different form.
Now I have a if then statement that looks to make sure a password is typed
in before it opens the form. I tried to get it to work by looking at a
field in a table, or form but it doesn't work.
Here is the code for the one that works with everything (encluding the password) in the code.

If Me![Password_txt].Value = "password" Then
DoCmd.Close , , acSaveNo
DoCmd.OpenForm "BlueSheetExtras"
DoCmd.OpenForm "BlueSheet"
ElseIf IsNull(Forms![Password]![Password_txt].Value) Then
MsgBox "Invalid Password"
Forms![Password]![Password_txt].Value = ""
ElseIf Not Me![Password_txt].Value = "Password" Then
MsgBox "Invalid Password"
Forms![Password]![Password_txt].Value = ""
End If

This one doesn't work unless the ExtraPassword_txt is visible and you
click on the ExtraPassword_txt after entering in the password on the
Password_txt text box. I don't want the password_txt visible though. The
password_txt is linked to a table field (also tried a query) that has the
password in it. Is they anyother way to get this to work?
If Me![Password_txt].Value = Me![ExtraPassword_txt].Value Then
DoCmd.Close , , acSaveNo
DoCmd.OpenForm "BlueSheetExtras"
DoCmd.OpenForm "BlueSheet"
ElseIf IsNull(Forms![Password]![Password_txt].Value) Then
MsgBox "Invalid Password"
Forms![Password]![Password_txt].Value = ""
ElseIf Not Me![Password_txt].Value = Me![ExtraPassword_txt].Value Then
MsgBox "Invalid Password"
Forms![Password]![Password_txt].Value = ""
End If
 

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