Combine (2) If Statements !

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
 
M

mscertified

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
 
D

Dan Artuso

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
 
D

Dan Artuso

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

Douglas J. Steele

Just out of curiousity, Dan, why the ElseIf instead of just Else? It seems
redundant...
 
D

Dan Artuso

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

Ken Snell [MVP]

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

Neil

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

Michel Walsh

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
 
N

Neil

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
 

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

Top