Jump to content

Number formating


This topic is 7823 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have a number iield which is currently formated to two decimal places. I need it to show a leading zero if the data is less than 10.

For example.

Suppose the data is 1.45

I need the format to show 01.45. However if the data is greater than 10 then I just want it to show the data - i.e. no additional zeros.

Anybody goy a suggestion to what should be an easy formating problem?

Thanks

Link to comment
Share on other sites

One answer to this would be to create a calculating field to display the number of the desired format, turn 'Allow Entry into field' off, and stack it on top of your existing number field. That way, when you tab to the field or click into it, the original value will be displayed (and may be edited), but at all other times, the calc value will be what is displayed.

In this respect, the functionality will appear to be the same as an auto-format applied to the field, but the difference is that you get total control over what is displayed. If the calculation is unstored, the impact on file size will be negligible.

You could, for instance, create and use a formula along the lines of:

Right("00" & Int(Number), Max(2, Length((Int(Number))))) & "." & Right(((Round(Number - Int(Number), 2) * 100) + 100), 2)

Which would permit your number to exceed 99, but would nevertheless place a leading zero on all numbers less than 10, plus would extend to two decimal places for all cases (including zeros - so 0 would be displayed as 00.00).

As well as turning 'Allow entry' off for the calculation field, you should ensure that the calculation field has 'Leave data formatted as entered' (if you have chosen a result type of number). A text 'result type' for the calc would be preferable in most cases.

Link to comment
Share on other sites

This topic is 7823 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.