set property value of decimal places

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

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