set format of text box variably

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???
 
A

Allen Browne

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.)
 
G

Guest

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.)
 
G

Guest

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.)
 

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