Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to Eliminate Decimals in Number convered ToText

Status
Not open for further replies.

Hillary

Programmer
Feb 15, 2002
377
US
I have a concatinated statement which contains a Count function of the numberic field {CSL_STD_DEMO_DISTRICT.ID_STD_DEMO_DISTRICT}, {CSL_STD_DEMO_SCHOOL.HOMEROOM_NUMBER}. When I convert it ToText the number shows as a decimal. How can I get the number to show as a whole number in the concatinated statement?

The formula is...

"There are "+ ToText (Count ({CSL_STD_DEMO_DISTRICT.ID_STD_DEMO_DISTRICT}, {CSL_STD_DEMO_SCHOOL.HOMEROOM_NUMBER}))+" students in Homeroom "+GroupName ({CSL_STD_DEMO_SCHOOL.HOMEROOM_NUMBER})


The result I see is There are [red]21.00[/red] students in Homeroom 111

What I would like to see is There are[red] 21 [/red] students in Homeroom 111

Thanks,

Hillary
 
Add another arguement to the totext function like this:

"There are "+ ToText (Count ({CSL_STD_DEMO_DISTRICT.ID_STD_DEMO_DISTRICT}, {CSL_STD_DEMO_SCHOOL.HOMEROOM_NUMBER}),"#")+" students in Homeroom "+GroupName ({CSL_STD_DEMO_SCHOOL.HOMEROOM_NUMBER})

~Brian
 
The second argument of the ToText function is the number of decimal places, so changing your formula to this should do it:

"There are "+ ToText (Count ({CSL_STD_DEMO_DISTRICT.ID_STD_DEMO_DISTRICT}, {CSL_STD_DEMO_SCHOOL.HOMEROOM_NUMBER}), 0)+" students in Homeroom "+GroupName ({CSL_STD_DEMO_SCHOOL.HOMEROOM_NUMBER})

-dave
 
As a more general solution, if you choose [Options] under the [File] menu and then click the [Fields] tab, you can change your defaults. Default a number not to show decimal places, for instance - you can always reset it for an individual field, or do Totext({your.number}, 2) to give it two decimal places, for instance.

Defaults save time, but can give problems when a Crystal report is used by several people who may have different values set.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top