Calculated expressions with text/numbers

  • Thread starter Thread starter Tina Hudson
  • Start date Start date
T

Tina Hudson

I'm trying to write a calculated expression that combines
text with numeric fields. I want the numeric fields to
show a certain number of decimals (only 2) so I've set
these fields to fixed format, 2 decimal places. But, when
I incorporate the field in a calculated expression, I
don't always get 2 decimal places. If the number is 2.00
then I get 2. If the number is 2.34 I get 2.3.
Sometimes, the number is alot more than 2 decimal places!
Go figure!

Example of my calculated expression:
="For the University Model Magnet, there is a total of " &
[ModelTS]& "teaching spaces, and capacity is " &
[ModelCapacity]& "."

I want it to read: For the University Model Magnet, there
is a total of 26.00 teaching spaces, and capacity is 581.

Thanks for any suggestions.
Tina
 
Try using Format Standard or Fixed with decimal places
set to Auto. That seems to work for me.

Good Luck!
 
Tina said:
I'm trying to write a calculated expression that combines
text with numeric fields. I want the numeric fields to
show a certain number of decimals (only 2) so I've set
these fields to fixed format, 2 decimal places. But, when
I incorporate the field in a calculated expression, I
don't always get 2 decimal places. If the number is 2.00
then I get 2. If the number is 2.34 I get 2.3.
Sometimes, the number is alot more than 2 decimal places!
Go figure!

Example of my calculated expression:
="For the University Model Magnet, there is a total of " &
[ModelTS]& "teaching spaces, and capacity is " &
[ModelCapacity]& "."

I want it to read: For the University Model Magnet, there
is a total of 26.00 teaching spaces, and capacity is 581.

The formatting properties only apply to the text box's
numeric value. Your expression results in a string so the
formating stuff is ignored.

Use the Format function in the ecpression:

="For the University Model Magnet, there is a total of " &
Format([ModelTS], "0.00") & "teaching spaces, and capacity
is " & [ModelCapacity] & "."
 
I'm trying to write a calculated expression that combines
text with numeric fields. I want the numeric fields to
show a certain number of decimals (only 2) so I've set
these fields to fixed format, 2 decimal places. But, when
I incorporate the field in a calculated expression, I
don't always get 2 decimal places. If the number is 2.00
then I get 2. If the number is 2.34 I get 2.3.
Sometimes, the number is alot more than 2 decimal places!
Go figure!

Example of my calculated expression:
="For the University Model Magnet, there is a total of " &
[ModelTS]& "teaching spaces, and capacity is " &
[ModelCapacity]& "."

I want it to read: For the University Model Magnet, there
is a total of 26.00 teaching spaces, and capacity is 581.

Thanks for any suggestions.
Tina

Once you combine text with a number you now have a string and you can
no longer use the control's Format property to set decimals. Instead
you'll need to format the number within the expression:

="For the University Model Magnet, there is a total of " &
Format([ModelTS],"#.00") & " teaching spaces, and capacity is " &
[ModelCapacity]& "."
 
Back
Top