I need help with this statement. It is looking at two text boxes and I want a
message to appear in a currently blank text box when conditions are met.
Private Sub Unit_Click()
If Me!TypeUnit = 1 Or 2 And Me!Totals > 15 Then
Me!Message = "Leak Rate Exceeded"
ElseIf Me!TypeUnit = 3 Or 4 And Me!Totals > 35 Then
Me!Message = "Leak Rate Exceeded"
Else
Me!Message = ""
End Sub
Thanks for the help!
You're missing the End If, and you can't use Or like that in VBA.
Private Sub Unit_Click()
If (Me!TypeUnit = 1 Or Me!TypeUnit = 2) And Me!Totals > 15 Then
Me!Message = "Leak Rate Exceeded"
ElseIf (Me!TypeUnit = 3 Or Me!TypeUnit = 4) And Me!Totals > 35 Then
Me!Message = "Leak Rate Exceeded"
Else
Me!Message = ""
End If
End Sub

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
>I need help with this statement. It is looking at two text boxes and I want
>a
[quoted text clipped - 10 lines]
>
> Thanks for the help!
You have to code it as:
If (Me!TypeUnit = 1 Or Me!TypeUnit =2) And Me!Totals > 15 Then
You need the parentheses for this to work.
It's probably easier to use a Select statement here. Just code:
Select case Me!TypeUnit
Case 1, 2
If Me!Totals > 15 Then
Me!Message = "Leak Rate Exceeded"
End If
Case 3, 4
If Me!Totals > 35 Then
Me!Message = "Leak Rate Exceeded"
End If
Case Else
Me!Message = vbnullstring
End Select
vbnullstring is a vb constant that represents "". It's slightly more
efficient to use it, since vb already has a variable defined to represent the
null string.
> I need help with this statement. It is looking at two text boxes and I want a
> message to appear in a currently blank text box when conditions are met.
[quoted text clipped - 9 lines]
>
> Thanks for the help!
Nikki - 24 Sep 2007 19:54 GMT
Thanks for the help- but when I put the new one in
Private Sub Unit_Click()
Select Case Me!TypeUnit
Case 1, 2
If Me!Totals > 15 Then
Me!Message = "Leak Rate Exceeded"
End If
Case 3, 4
If Me!Totals > 35 Then
Me!Message = "Leak Rate Exceeded"
End If
Case Else
Me!Message = vbNullString
End Select
It is still not working. Could there be something else I did wrong? I have
checked all the names- It is looking at a text box bound to an equation-is
that a problem?
Thanks again so much for the help!

Signature
Thanks,
Nikki
> You have to code it as:
>
[quoted text clipped - 34 lines]
> >
> > Thanks for the help!
Nikki - 24 Sep 2007 20:02 GMT
Ignore last post -
Thank you for the help it works great.

Signature
Thanks,
Nikki
> You have to code it as:
>
[quoted text clipped - 34 lines]
> >
> > Thanks for the help!