Nested IF Problem

  • Thread starter Thread starter D S via AccessMonster.com
  • Start date Start date
D

D S via AccessMonster.com

Ihave this NestedIF statement that doesn't seem to be working. Does anyone
know why?
Thanks
DS

Private Sub Command67_Click()
If Me.Pat > 0 Then
Forms!OveringHidden!Text7 = CCur(Me.Pat)
DoCmd.Close acForm, "OveringAmount"
Forms!OveringHidden.Visible = True
If Forms!OveringHidden!Text7 > Forms!OveringHidden!Text4 Then
DoCmd.Open "OveringTooMuch"
Else:
Forms!OveringHidden.Visibe=True
End If
Else: IsNull (Me.Pat)
Forms!OveringAmount.Visible = False
DoCmd.OpenForm "NoOveringAmount"
End If
End Sub
 
D S via AccessMonster.com said:
Ihave this NestedIF statement that doesn't seem to be working. Does
anyone know why?
Thanks
DS

Private Sub Command67_Click()
If Me.Pat > 0 Then
Forms!OveringHidden!Text7 = CCur(Me.Pat)
DoCmd.Close acForm, "OveringAmount"
Forms!OveringHidden.Visible = True
If Forms!OveringHidden!Text7 > Forms!OveringHidden!Text4 Then
DoCmd.Open "OveringTooMuch"
Else:
Forms!OveringHidden.Visibe=True
End If
Else: IsNull (Me.Pat)
Forms!OveringAmount.Visible = False
DoCmd.OpenForm "NoOveringAmount"
End If
End Sub

Your use of colons after your Else keywords is undesirable, and your
lack of indentation confuses the matter. If you reformat your code like
this ...

If Me.Pat > 0 Then
Forms!OveringHidden!Text7 = CCur(Me.Pat)
DoCmd.Close acForm, "OveringAmount"
Forms!OveringHidden.Visible = True
If Forms!OveringHidden!Text7 > Forms!OveringHidden!Text4 Then
DoCmd.Open "OveringTooMuch"
Else
Forms!OveringHidden.Visibe=True
End If
Else
IsNull (Me.Pat)
Forms!OveringAmount.Visible = False
DoCmd.OpenForm "NoOveringAmount"
End If

.... it becomes clear that this line

IsNull (Me.Pat)

doesn't really make any sense. Did you want that to be another "If"
condition, or an "ElseIf" condition, like this:

ElseIf IsNull (Me.Pat) Then
Forms!OveringAmount.Visible = False
DoCmd.OpenForm "NoOveringAmount"
End If

? Or did you have something else in mind?
 
Back
Top