HELP!! Problem with the number of decimals in calculations

G

Geo

In a query I make multiplying operations with two fields
quantity_entry: type - number
field size - double
format - standard
decimal places - 3
and

Unit_Price: type - currency
decimal places - 2
The quantity_entry can be in "m" or "kg", so when I enter the value in m, i
get the calculatet value in :kg", and the same for the price (unit_Price (m)
<-->Unit_price(kg))
I need to get a calculated field Price (= [quantity_entry]*[Unit_Price] with
two (2) decimals.
I tried to set in the query, for the calculated field [Price] the format
"standard" and the decimal places to 2, but it is only limiting the number
of displayed decimals, in fact the number having more then 2 decimals.
In consequence, if I entered the [quantity_entry] in "m" and I need to
reduce the quantity with a value [quantity_withdraw] in "kg" with the
Unit_price (kg), When I introduce the price with 2 decimals the same with
the one displayed for the entry, access doesn't recognize the price as being
the same, because it is not equal at the third decimal.
WHAT CAN I DO?
I would apreciate any help.
Thank you
 
A

Allen Browne

Round the expression to 2 places, i.e.:
= Round([quantity_entry]*[Unit_Price], 2)

It would also be a good idea to force the result into the Currency type,
i.e.:
= CCur(Round([quantity_entry]*[Unit_Price], 2))

That expression will error if either field is Null, so you really need:
= CCur(Nz(Round([quantity_entry]*[Unit_Price], 2), 0))

Ultimately it is best to put that whole expression into the Field row of a
query, and base use the query as the RecordSource for your form. That makes
it quick and easy to sum the expression, and the updates work nicely.
 

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