set format of text box variably

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Either using to textboxes on top of each other and setting visibility or some
other way you suggest, how can I show a value either as a percentage or as an
integer based on what the value is???
 
You could use an expression in the Control Source of the text box.

Example:
=IIf(Abs([MyNum]) < 1, Format([MyNum], "Percent"), Format([MyNum], "#,##0")

Be sure to change the Name of the text box as well. Access gets confused if
a control has the same name as a field in the report's RecordSource, but it
is bound to something else.

Also, the Format() outputs a text value, so if you want to do anything
numeric (sum, average, ...) you will need to refer to the field (which is
numeric), not the text box (which is string data.)
 
Thank you Allen:

I am just trying to get the numbers to display correctly in the report, ie.
..6898 as 68.98%, 23 as 23 etc.

I am anxious to try this, appreciate your time and suggestion very much
--
Jeff C
Live Well .. Be Happy In All You Do


Allen Browne said:
You could use an expression in the Control Source of the text box.

Example:
=IIf(Abs([MyNum]) < 1, Format([MyNum], "Percent"), Format([MyNum], "#,##0")

Be sure to change the Name of the text box as well. Access gets confused if
a control has the same name as a field in the report's RecordSource, but it
is bound to something else.

Also, the Format() outputs a text value, so if you want to do anything
numeric (sum, average, ...) you will need to refer to the field (which is
numeric), not the text box (which is string data.)
 
Allen:

Worked like a charm, Thanks again
--
Jeff C
Live Well .. Be Happy In All You Do


Allen Browne said:
You could use an expression in the Control Source of the text box.

Example:
=IIf(Abs([MyNum]) < 1, Format([MyNum], "Percent"), Format([MyNum], "#,##0")

Be sure to change the Name of the text box as well. Access gets confused if
a control has the same name as a field in the report's RecordSource, but it
is bound to something else.

Also, the Format() outputs a text value, so if you want to do anything
numeric (sum, average, ...) you will need to refer to the field (which is
numeric), not the text box (which is string data.)
 
Back
Top