Nested IF Problem

  • Thread starter D S via AccessMonster.com
  • 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

Dirk Goldgar

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?
 

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

Similar Threads

Sloooow CODE 1
Data Entry Validation 1
Nested IF 7
INSERT Syntax Problem 2
Nested If 3
Ctl Reference 4
Multiple SQL Stuff 6
NotInList Firing Problem 12

Top