Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Multiple Conditions in Macro 1

Status
Not open for further replies.

kmkland

Technical User
Dec 15, 2004
114
US
I have created a security form (frmSecurity) which is based on tblSecurity. (tblSecurity lists 3 different passwords.) In frmSecurity, I have an unbound text field (txtPWordInput) with the Input Mask set to Password and nothing in the Control Source. I have another unbound text field (txtPassword) bound to the Password field in tblSecurity and Visible is set to False.

The command button on frmSecurity has this code attached to it:
Code:
Private Sub btnEnterPassword_Click()
If Me.txtPWordInput = Me.txtPassword Then
DoCmd.RunMacro "PasswordSecurity"
Else
MsgBox "The password entered is incorrect"
End If
End Sub
The macro "PasswordSecurity" has the following conditions:
Code:
[b]Condtion						                   Action        Argument[/b]
[Forms]![frmSecurity]![txtPWordInput]='password1'  OpenForm  	frmEmpInfo
[Forms]![frmSecurity]![txtPWordInput]='password2'  OpenForm  	frmEmpID
[Forms]![frmSecurity]![txtPWordInput]='password3'  OpenReport    rptEmpAbs

Now, whenever I enter a correct password from the tblSecurity Password field into the frmSecurity form, the message box is displayed. What am I doing wrong!?!? I think that the answer lies in the conditions of my macro.
Any and all help will be greatly appreciated!!!

(I have used previous enquiries from the forums to help with this matter, but I still have not yet been able to solve my problem.)

Rgds,
kmkland
 
Why not simply this ?
Private Sub btnEnterPassword_Click()
Select Case Me.txtPWordInput
Case 'password1'
DoCmd.OpenForm "frmEmpInfo"
Case 'password2'
DoCmd.OpenForm "frmEmpID"
Case 'password3'
DoCmd.OpenReport "rptEmpAbs"
Case Else
MsgBox "The password entered is incorrect"
End Select
End Sub

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hiya PH.

Well, I tried your code but it gives me an error message: Compile error: Syntax error...and then highlights the "Case 'password1' " line.

Not sure where to go from here....Any suggestions??

Thanks so much!!
kmkland
 
Sorry for the typos, replace the single quotes by double quotes
...
Case "password1"
...
Case "password2"
...
Case "password3"
...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
brilliant! worked like a charm!
cheers for all the help PH!!
kmkland
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top