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.
 

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

Back
Top