|
-
Nov 10th, 2006, 05:48 AM
#1
Thread Starter
Lively Member
[RESOLVED] number formats
Hi
I'm using Crystal Reports for Visual Studio 2005. I'm having problems with displaying numbers in the correct format.
I've gone into Design > Default Settings menu and set the format of number fields to no decimal place (i.e. 1 instead of 1.0) and taken out the thousand separator. But this doesn't seem to have made a difference.
On one report, the numbers show ok (e.g. 54) on the report preview but when I run it through my application, the numbers are showing with decimal places (e.g. 54.00).
On another report, the ids of the records shown in the report appear in the group tree and have thousand separators on them when run through my application. As with the other report, they appear correctly in the report preview!
How can I make the format show correctly when running the report through my application?
Thanks
-
Nov 10th, 2006, 06:32 AM
#2
Re: number formats
Right click on the your field that is on the crystal report and click on the format object.
Select the format from there click on the number.
Select there decimal place=0
-
Nov 10th, 2006, 06:46 AM
#3
Thread Starter
Lively Member
Re: number formats
Thanks, I tried this and it did work when displaying the field independently on the form. I had wanted to build the field into a Formula field so that I can combine it with text and it doesn't work then. It's not essential that I put it in the formula but surely I could get it to work within a formula too?
-
Nov 10th, 2006, 06:55 AM
#4
Re: number formats
I did not understand you problem.
What type of formula you want??
-
Nov 10th, 2006, 07:10 AM
#5
Thread Starter
Lively Member
Re: number formats
I created two summary fields, one to count the number of records and one to average the values in a particular field. The code behind those fields shows thus:
Count ({reportview_TimeToRegister.PersonID}, {reportview_TimeToRegister.Mode})
Average ({reportview_TimeToRegister.DaysToRegister}, {reportview_TimeToRegister.Mode})
This is a formula I'm using to combine text with the count and the average summary fields:
'Average for Mode = ' & {reportview_TimeToRegister.Mode}
& '(' & Count ({reportview_TimeToRegister.PersonID}, {reportview_TimeToRegister.Mode}) & ' detail records) ' & Average ({reportview_TimeToRegister.DaysToRegister}, {reportview_TimeToRegister.Mode})
when shown within the formula, both the Count and Average show with decimal places e.g. 54.00 but when shown independently on the report they show correctly e.g. 54
-
Nov 10th, 2006, 11:16 AM
#6
Re: number formats
The Format applies to a field on the report, not the database field and each field has it's own Format.
Format the database fields in the formula using a string function like ToText or CStr.
'Average for Mode = ' & ToText({reportview_TimeToRegister.Mode},0) & '('...
Note: Check the help file for ToText (or To_Text), I couldn't remember the exact syntax.
-
Nov 10th, 2006, 11:41 AM
#7
Thread Starter
Lively Member
Re: number formats
 Originally Posted by brucevde
The Format applies to a field on the report, not the database field and each field has it's own Format.
Format the database fields in the formula using a string function like ToText or CStr.
'Average for Mode = ' & ToText({reportview_TimeToRegister.Mode},0) & '('...
Note: Check the help file for ToText (or To_Text), I couldn't remember the exact syntax.
I did try Truncate(({reportview_TimeToRegister.Mode},0) before but that didn't work. I'll try the ToText version. Thanks!
-
Nov 10th, 2006, 11:47 AM
#8
Thread Starter
Lively Member
Re: number formats
 Originally Posted by brucevde
The Format applies to a field on the report, not the database field and each field has it's own Format.
Format the database fields in the formula using a string function like ToText or CStr.
'Average for Mode = ' & ToText({reportview_TimeToRegister.Mode},0) & '('...
Note: Check the help file for ToText (or To_Text), I couldn't remember the exact syntax.
Brucevde, you're a genius! ToText works perfectly! Thank you!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|