Results 1 to 8 of 8

Thread: [RESOLVED] number formats

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    Resolved [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

  2. #2
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Arrow 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

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    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?

  4. #4
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: number formats


    I did not understand you problem.
    What type of formula you want??

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    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

  6. #6
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    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.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    Re: number formats

    Quote 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!

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Aug 2006
    Location
    UK
    Posts
    96

    Re: number formats

    Quote 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
  •  



Click Here to Expand Forum to Full Width