Formatring numbers to a variable set of decimal places

G

Guest

How do i format a number field on a form to the numberof decimals palce
indicated by a second field.

Ie, if the number is 2.0437, and the second field contains the number 5,
then i want to see 2.04370 (5 decimal places), conversely, if the number in
the second field is 2, i want to see 2.04 (2 decimal place).

Pat
 
A

Allen Browne

Assuming fields named MyNumber (Double) and DecPlaces (Byte), try a text box
with Control Source of:

=Format([MyNumber], "0." & String([DecPlaces], "0))

Naturally you will not be able to enter data into this control.

If this is for Form view (not Continuous or Datasheet), you could set the
Format property of the text box to Fixed, and the programmatically set the
DecimalPlaces property of the text box in Form_Current.
 

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