Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: New Line Character Post Reply Post New Topic
Author Message
RealQMan
Newbie
Newbie
Avatar

Joined: 22 Aug 2007
Online Status: Offline
Posts: 25
Quote RealQMan Replybullet Topic: New Line Character
    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



IP IP Logged
wattsjr
Groupie
Groupie
Avatar

Joined: 25 Jun 2007
Location: United States
Online Status: Offline
Posts: 51
Quote wattsjr Replybullet 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
IP IP Logged
RealQMan
Newbie
Newbie
Avatar

Joined: 22 Aug 2007
Online Status: Offline
Posts: 25
Quote RealQMan Replybullet 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?



IP IP Logged
wattsjr
Groupie
Groupie
Avatar

Joined: 25 Jun 2007
Location: United States
Online Status: Offline
Posts: 51
Quote wattsjr Replybullet 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
IP IP Logged
wattsjr
Groupie
Groupie
Avatar

Joined: 25 Jun 2007
Location: United States
Online Status: Offline
Posts: 51
Quote wattsjr Replybullet 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
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.