Combine (2) If Statements !

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

I need to combine these in to one of possible.
the code is run on the current event.
Also the second one does not work, it does not make Due = False
That is if the second if statement Text388 equals 0 or is less than 0 then
Due = False

If Nz(Me!Text388) > 0 Then Me!Due = True
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSaveRecord

If Nz(Me!Text388, 0) < 0 Then Me!Due = False
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSaveRecord
 
Every If must have a matching End If

If Nz(Me!Text388, 0) > 0 Then
Me!Due = True
Else
Me!Due = False
End If
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSaveRecord
 
Hi,
Something like this maybe:

If Nz(Me.Text388,0) > 0 Then
Me.Due = True
ElseIf Nz(Me!Text388, 0) <= 0 Then
Me.Due = False
End If
 
Not if you write the statement all on one line like he did:
If Nz(Me!Text388,0) > 0 Then Me!Due = True

is the correct syntax.
 
Just out of curiousity, Dan, why the ElseIf instead of just Else? It seems
redundant...
 
Hmm... you're right.
For some reason I thought there might be another possible 'condition' but
I guess a number is either > 0 or <= 0!
 
Dan Artuso said:
Hmm... you're right.
For some reason I thought there might be another possible 'condition' but
I guess a number is either > 0 or <= 0!


not counting imaginary numbers, of course.....
< g >
 
Just to complicate things :-), it might of just been easier to use IIF on
this occasion

IIF(Nz(Me!Text388) > 0, Me!Due = True, Me!Due = False)

might it?

Neil.
 
Hi,


or


Me!Due = CBool( 0 < Nz(Me!Text388, 0) )



since the comparison with 0 is already the answer (CBool just makes it more
evident, and can be removed ).



Vanderghast, Access MVP
 
now your just showing off! :-)

Neil.

Michel Walsh said:
Hi,


or


Me!Due = CBool( 0 < Nz(Me!Text388, 0) )



since the comparison with 0 is already the answer (CBool just makes it
more evident, and can be removed ).



Vanderghast, Access MVP
 
Back
Top