Calculated expressions with text/numbers

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
 
S

Sue

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

Good Luck!
 
M

Marshall Barton

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] & "."
 
F

fredg

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]& "."
 

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