If statement in a form

P

Purnima Sharma

I have designed an unbound form. Based on the value of code in the text box,
When a person clicks OK button, it should open the appropriate report e.g.

If Commission.Form_DirectorCommissionForm.TextPassword = "fj01" Then
DoCmd.OpenReport "DirectorSales", acViewPreview, , , , acDialog
End If

There are five possible codes. I am having trouble with putting a message
box for invalid code i.e. if the code is none of the five values, it should
give a message box asking the person to check his password. The codes are
secured codes ao, they cannot be shown to the people. How do you write
if..Else If statements in Access?
I appreciate if someone can help me in this regard. Thanks.
Purnima
 
B

Brendan Reynolds

Public Sub TestSub4(ByVal x As Integer)

MsgBox "Using If ..."

If x = 1 Then
MsgBox "x=1"
ElseIf x = 2 Then
MsgBox "x=2"
Else
MsgBox "x is neither 1 nor 2"
End If

MsgBox "Using Select Case ..."

Select Case x
Case 1
MsgBox "x=1"
Case 2
MsgBox "x=2"
Case Else
MsgBox "x is neither 1 nor 2"
End Select

End Sub
 
Top