If statement in a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

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

Back
Top