Print Page | Close Window

New Line Character

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=1431
Printed Date: 05 May 2024 at 8:58am


Topic: New Line Character
Posted By: RealQMan
Subject: New Line Character
Date Posted: 02 Oct 2007 at 8:14am
Hello,

How do i format a line to be separated by a new line character? I am using a formula that outputs a string and I would like to know how to separate that string into two lines.

Good Day ->  Good  
                      Day






Replies:
Posted By: wattsjr
Date Posted: 02 Oct 2007 at 3:16pm
Hi RealQMan,
 
The "line feed" character that you're looking for is "Chr(10)".  You imbed, or add, this into your string.  For example:
 
"Now is the time" + Chr(10) + "for all good men"
 
or
 
String-Part-a + Chr(10) + String-Part-b
 
When you insert your formula into the report, be sure to check the "Can Grow" option in the Formula Editer screen.
 
Regards,


-------------
-jrw


Posted By: RealQMan
Date Posted: 03 Oct 2007 at 8:24am
Thanks,
That was a great suggestion. It work like a charm. There is one thing i would like to improve on my formula. My formula displays the abbreviation of the month value inside a date. It means if the date value is "2007-10-03", the formula will return "Oct".

My formula is as such
Year(DateValue("2007-10-03")) + Chr(10) + MonthName(Month(DateValue("2007-10-03")))

What i would like to return is
                                                        2007
                                                        Oct

So, should be year follow by a new line and the month abbreviation.
Instead, what it return was
                                                       2,007.00
                                                       Oct

I can to use string functions to modify the year, like extracting only the first five character of the year. But is there a easy way of doing this?





Posted By: wattsjr
Date Posted: 03 Oct 2007 at 9:57am
Hi RealQMan,
 
I'm not sure what the source of your date is, but I'm assuming that it is a date field on your record.
 
If you replace the "{DATECREATED}" in the following formula with your own date field, it should do what you are looking for.
 
CStr(Year ({DATECREATED}),"0") + Chr(10) + MonthName(Month({DATECREATED}), True)
 
Good luck,


-------------
-jrw


Posted By: wattsjr
Date Posted: 03 Oct 2007 at 10:38am
I just had another thought.
 
If you're just using the formula to format your date field, there is a more direct formula-free approach.
 
You might try the following:
 
1. Create (Insert) a Text Object in your report.
2. Insert ( Drag & Drop) your Date Field into the Text Object  - Twice.
3. Resize the text object to allow for the 2 lines.
4. Use the "Enter"key to place the 2nd Date field under the 1st date field.
5. Right-click on the 1st date field and choose the Format(Datefield) option.
6. Click on the "Customize" button.
7. In the formatting options, select "None" for the Month & Day
8. For the 2nd date field, do the same thing, only choose "Mar" for the Month and "None" for Day & Year.
 
Now you have options.
 


-------------
-jrw



Print Page | Close Window