set property value of decimal places

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
Back
Top