Calculation in reports - negative number

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating a calculation in a report which occassionally creates a
negative number. Is there any way I can place a 0 in this field if a
negative number is generated?
 
I am creating a calculation in a report
which occassionally creates a
negative number. Is there any way I
can place a 0 in this field if a
negative number is generated?

IIF ((yourcalculation)<0, 0, (yourcalculation))

replace both instances of (yourcalculation) with your calculation. If you
are doing your calculation in code, you can simplify just by using an

If ... Then
....
End If

structure instead of the IIF, but the IIF will work in a Control Source
expression, too.

Larry Linson
Microsoft Access MVP
 
I am creating a calculation in a report which occassionally creates a
negative number. Is there any way I can place a 0 in this field if a
negative number is generated?

Use an Unbound control.
Set it's control source to:

=IIf([FieldA]-[FieldB]>0,0,[FieldA]-[FieldB])

Where [FieldA]-[FieldB] represents whatever your actual calculation
is.
 
D,
Place this calculation in your field...
=IIF(YourCalculation < 0, 0, YourCalculation)
that should do it.
 
Back
Top