Decimal points only if it has decimal values. No decimal if it is a full number (1 Viewer)

jack555

Member
Local time
Today, 23:10
Joined
Apr 20, 2020
Messages
93
In the number filed having a mix of numbers like 1.35 or 0.22 or 3. However, I can see all with two digits including full number like 3.00 or no decimals for like 0.22 as 0. Which is the right format to solve this problem. Would like to see display decimal digits only if it having decimal value. Tried single, double, long/short integer etc. Thank you.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 19:10
Joined
Sep 12, 2006
Messages
15,614
You could test for it being an integer or not, and then display differently. this sort of thing
Not in a table, though, but then users shouldn't really be using tables directly.

Code:
if int(var) = var then
     integer
else
     real number
end if
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 06:10
Joined
Jan 20, 2009
Messages
12,849
In the Format property of the field or control
Code:
0.##
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:10
Joined
May 7, 2009
Messages
19,169
bring your underlying Table in design view and Remove any Formatting on that particular field.
do the same on the form/subform that uses the table as row source./
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:10
Joined
Feb 19, 2002
Messages
42,972
Since the format applies to ALL rows, you cannot have a different format for some rows unless you use the Format() property inside an IIf() in a query and that will render the field not updateable.

To always see two decimal places, change the format property on the form/report to show only two decimal places and the form/report will always show 2 even for an integer so 10 = 10.00 and 10.2 = 10.20

Do not format the column in the table. Although this may seem to be more convenient, it hides the actual value and you will end up some day wondering why a series of values don't add up "correctly"
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 06:10
Joined
Jan 20, 2009
Messages
12,849
You really only have two Format Property choices.

Show up to two decimal places if they are present but the decimal point will always be displayed.
Code:
0.##
Show however many decimal places are in the number entered and only show the point if there are decimal places.
Code:
General Number
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 06:10
Joined
Jan 20, 2009
Messages
12,849
Using 0.## doesn't do what the poster is asking for.
Technically it does. They didn't say they anything about suppressing the decimal point, just the digits.
Would like to see display decimal digits only if it having decimal value.

However the following is definitely not true.
Since the format applies to ALL rows, you cannot have a different format for some rows unless you use the Format() property inside an IIf() in a query

'General Number' displays the decimal digits only if they are present (and suppresses the decimal point if not required). I only included '0.##' as an option in case they wanted a maximum of two decimal digits and didn't mind the decimal point. 'General Number' will include all decimal digits.
 

Users who are viewing this thread

Top Bottom