Adding Plus/Minus Sign to Calculated Control in Report

J

JDB

I am trying to add a '+' and '-' to a calculated control.

=IIf([txtq1pre]-[txtq1post]>=0,"+", "-") returns the appropriate sign.

However, when I try to add something after the sign, the control return a
huge number.

For example, =IIf([txtq1pre]-[txtq1post]>=0,"+" &
([txtq1pre]-[txtq1post]),"-"&([txtq1pre]-[txtq1post])) yields a large
number, when the underlying two numbers [txtq1pre] and [txtq1post] are both
less than 5.

Any help on my syntax?
 
M

Marshall Barton

JDB said:
I am trying to add a '+' and '-' to a calculated control.

=IIf([txtq1pre]-[txtq1post]>=0,"+", "-") returns the appropriate sign.

However, when I try to add something after the sign, the control return a
huge number.

For example, =IIf([txtq1pre]-[txtq1post]>=0,"+" &
([txtq1pre]-[txtq1post]),"-"&([txtq1pre]-[txtq1post])) yields a large
number, when the underlying two numbers [txtq1pre] and [txtq1post] are both
less than 5.


You syntax is fine, but depending on what you mean by "huge
number", you calculation and/or formatting may be off.

For example, if the numbers are floating point numbers then
you have to decide how you want to round and display the
result. It might be as simple as:
=IIf(txtq1pre- txtq1post >0, "+", "") & Format(txtq1pre -
txtq1post, "0.00")
 

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