Bobmcguire
Bobmcguire

Reputation: 11

How to conditionally format decimal places in Access

I was wondering how to conditionally format decimal places for certain text boxes in a report? I need to so certain text boxes show 2 decimal places if the value in them is > 1 and 3 decimal places if the value in them is < 1.

Upvotes: 0

Views: 1038

Answers (1)

Andre
Andre

Reputation: 27644

You can't do this with conditional format (number formats aren't available there), but you can do it in the query that is the record source for the report:

SELECT 
    IIf([myNumber]>=1, 
        Format([myNumber],"0.00"), 
        Format([myNumber],"0.000")
        ) AS FormattedNumber,
    ... other fields ...
FROM myTable

Note that this yields a string, not a number, so you can't use this field to calculate a sum or similar.

Upvotes: 1

Related Questions