Formatring numbers to a variable set of decimal places

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
Back
Top