Header Ads

  • Recent Posts

    CHR and ASCII values useful in Crystal Reports, SQR, VB, Oracle.....

    Recently my friend told me a requirement in Crystal Reports where he had to induce carriage return and line breaks based on a business logic which wasn't trivial. While I had to analyze the various chr options that would suit the requirement, I was searching for sites which would give me chr values in crystal reports and their functions(characters).

    First of all, what is CHR?
    Each character has an associated ASCII value to it. To find ASCII value of a string we will simply use the function ASCII(‘A’or ‘a’….)

    If we have the ASCII value and want to find the corresponding character then we use CHR(ASCII#). For example, CHR(65) returns ‘A’. We can execure CHR(ASCII#) and ASCII('character for ascii') in ORACLE database and get the corresponding values. In Crystal Reports CHR() is replaced by CHRW().
    Below are the important values which would be handy right from SQR to Crystal Reports in several occasions:

    CHR values in Crystal Reports

    • Character 8 - Chr(8): Backspace
    • Character 9 - Chr(9): Tab (vbTab)
    • Character 10 - Chr(10): Line Feed Return (vbLf)
    • Character 11 - Chr(11): Shift+Enter (vbVerticalTab)
    • Character 12 - Chr(12): Page Break (vbFormFeed)
    • Character 13 - Chr(13): Carriage Return
    • Character 14 - Chr(14): Column Break
    • Character 15 - Chr(15): Shift In
    • Character 32 - Chr(32): Space
    A very simple example: Usage of "Jan" + CHR(10) + "20th" in a Crystal formula displays the below: Jan 20th
    These two functions can be used in any programming language(I firmly believe unless a very old crap programming language/legacy system doesn't).

    For my requirement in Crystal Reports, I wrote the required IFs and FORs in Crystal Syntax and used CHRW(32), CHRW(10), CHRW(12) and CHRW(13) to meet my customization needs. Here is the link VB_Chr_Values where CHR and ASCII values are found from 1 to 255. Few of them work only with VB or behave differently with VB.

    This post sounds simple even for me; however considering the time I had vetted(after forgetting) to find the required ASCII numbers to be passed in CHRW() function in Crystal and VB syntax, I think this is worth a post that could save my time in future.


    1. Very useful, just what I was looking for.

    2. Very useful, thanks

    3. Thank you. Very helpful.
      I used the chr(9) in a formula where I needed
      account# then a tab then my period delimiter.
      I used
      but I still get a space in my tab delimited file. is there a problem with this formula?

    4. doesn't look wrong in any way. I suspect the editor you are opening shows tab as a single space.

      1. thanks so much! It could be that.

    5. how can i substitute Carriage Return with any value in peoplecode.

      1. hi @Srinivasulu Kamineni, can you elaborate please.


    Please refrain for marketing messages and unnecessary back links.

    Post Top Ad

    Post Bottom Ad