INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Formula Help

How to print text vertically by HowardHammerman
Posted: 30 May 02

A tip in the May, 2002 issue of the Crystal Care eNews for Crystal Reports newsletter showed how to take the text in a text object and print the letter vertically.  

BUT suppose you wanted to print a character field from your database in the same way?

In the following example we are using a For loop. This is available in Crystal 8.5 and above. We will print the field NAME vertically.

Here is how to do it:

Create a formula field with the following syntax:

WhilePrintingRecords;
numbervar stlen := length(trim({EMPLOYEE.NAME}));
numbervar k ;
local stringvar output;
for  k := 1 to  stlen  do
(
output := output + {EMPLOYEE.NAME}[k]+chr(13);
);
output := output + chr(13)

Insert the formula in your report and then right-click, pick ôFormat Fieldö and
Check the ôcan growö property.

Here is how it works:  
Line 2 stores the length of the field striped of blanks into the variable stlen.
Line 3 declares a number variable, k. We will use this to control the number of loops.
Line 4 declares a string variable to use to store the output. It is important to include the ælocalÆ qualifier or the field will keep growing from record to record!
Line 5 sets up the loop.  We will go through the loop the number a number of times equal to the current value of stlen.
Line 7 parses the database field. The sub-string operator [ ] (brackets) picks out the kth  letter of the field and appends it to the growing output string field. After each letter we are inserting a hard return. The CHR function translates a number to its ASCII equivalent. CHR(13) is equivalent to pressing the ôreturnö key on your keyboard.
Line 9 adds one more return at the end of the string for formatting purposes.

Back to Business Objects: Crystal Reports 1 Formulas FAQ Index
Back to Business Objects: Crystal Reports 1 Formulas Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close