Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display last 10 lines of text if text exceeds 10 lines

Status
Not open for further replies.

ERob

MIS
Oct 25, 2001
11
US
We are using crystal reports and a access database to track current project. We sometimes put large amounts of data into this. We have created a report to make available to other departments, but sometimes the long lasting projects have to much data. What I am looking for is something that will allow me to limit a field to 10 lines, if the field is larger than 10 lines, insert the last 10 lines. Is that clear?? Thanks for any help.

Rob
 
I am assuming that you are talking abount a memo field.
I am sure you know that Crystal already has a way to limit the display to the FIRST N lines. Your problem is different.

I think the best way is to create a formula field using a DO loop and an array.

The logic would work someting like this:

stringvararray proj;
numbervar charkount := length(trim({table.field}));
numbervar lines := truncate(charkount/40 ) ;
numbervar kount := 1;
for kount := 1 to lines do
(proj[kount] := {table.field}[kount to kount +40]);
if remainder(charkount,40)>0 then
(proj[lines+1] := {table.field}[lines+41 to charkount];
lines := lines +1;)
stringvar output;
for kount := kount - 10 to lines do
(output := output +proj[kount]);
output

Place the resulting formula field in your report and format it as required. In the above I assumed a line of 40 characters. adjust as required. Items I did not deal with:

What about memo field with less than 10 lines?
What about dividing words in the middle?

I bet Ken Hammady will respond with some nifty ideas.

Howard

Crystal Reports training, consulting, books, training material and on-site support. Scheduled traing in 8 cities.
800-783-2269
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top