set property value of decimal places

  • Thread starter Patrick Stubbin
  • Start date
P

Patrick Stubbin

how can i use code to set the property value (decimal places) of a field
based on the contents of another field.

ie field1 = 3

then field2 is displayed as eg 5.000


and if field1 = 7

then field2 is displayed as 5.0000000
 
A

Allen Browne

If you wanted to do this in a continuous form, I doubt there is a very
simple solution.

For a normal form (single record view), you could use set the Format
property of the text box to:
Fixed
and use the Current event of the form to set the DecimalPlaces property of
the text box, based on the value in the other field. Something like this:

Private Sub Form_Current()
Me.Field1.DecimalPlaces = Nz(Me.Field2, 2)
End Sub
 
Top