Print Page | Close Window

How to divide the field,depending on number lines

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Tips and Tricks
Forum Discription: Have you learned some great tricks to share with the group? Post them here!
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=12146
Printed Date: 03 May 2025 at 4:33pm


Topic: How to divide the field,depending on number lines
Posted By: denhors
Subject: How to divide the field,depending on number lines
Date Posted: 25 Jan 2011 at 3:04am
I have a report with more details how split the field from the database that begins in the Detail a to continue after specified number of lines in the second detail, and then in the third ... (1 field - more details)
Example:
I need to split the field with 100 lines to 3 detail;
Detail a: 1 to 40 lines
Detail b: 41 to 80 lines
Detail c: 81 to end.
Thx



Replies:
Posted By: lockwelle
Date Posted: 25 Jan 2011 at 3:22am
3 formula:
 
first40:
LEFT({table.field}, 40)
 
middle40:
MID({table.field}, 41, 40)
 
last20:
MID({table.field}, 81)
 
place each formula in the correct detail section and you should be done.
 
HTH


Posted By: denhors
Date Posted: 26 Jan 2011 at 12:06am
Thanks for your reply, but I need a separating by lines (rows), this is by number of characters.
If you have an idea, feel free to share with me;)
Example fields:
1 line
2 lines
:
.
100 lines


Posted By: lockwelle
Date Posted: 27 Jan 2011 at 3:09am

sorry, missed the lines part

well, then my solution would be to count the carriage return/line feeds and use that to split the lines up.  You would probably want to keep a counter so that you don't keep recounting the lines.  You would want to use a loop, probably a WHILE loop (I don't use loops too often, so look in CR help for the syntax).  Your other friend will be INSTR to find the position of the carriage return/line feed( CHRW(13) +  CHRW(10) ).
 
HTH



Print Page | Close Window