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!

Alignment of text when changing fonts

Status
Not open for further replies.

agorjest

Technical User
Oct 23, 2007
51
US
CR2008. Using a Format Field/Font/Size formula for a string field in order to limit the field to a certain length while still displaying the entire sentence of text on one line (I prefer not using the "Can Grow" option). Font formatting formula goes like this:

if length ({workorder.description}) in [62-63.999] then 8 else
if length ({workorder.description}) > 64 then 7.5 else 9

The formula does what I want, but the text appears shifted upward in the fields where the font is smaller and it is uneven with neighboring fields' text, even though all field heights are the same. I've tried aligning the baseline of the field to the baselines of the neighboring fields, but the text still looks higher, even though all the fields are in the same vertical position of 5.1.

Anyone know of how I can format this to eliminate this problem?

Thanks...
 
Unfortunately, Crystal doesn't let you do vertical alignment - text is placed based on the position of the TOP of the text box, not the bottom. So, if you make the font smaller, the bottom of the text moves up instead of the top moving down. Likewise, if you make it larger, the bottom moves down instead of the top moving down.

Since you can set the size and position of a text box based on a formula, here's what I would do:

1. Do a test run of the report with the font at the smaller size and "can grow" turned on. This will shrink the text box to the font size. Align the bottom with the other fields. Right click and select "Size and Position". Get the Y and Height numbers.

2. Do another test run where the font is the larger size. Again, get the Y and Height numbers.

3. Turn off Can Grow.

4. Go back to "Size and Position". Use the formula buttons to set the Y and Height values programmatically based on the same criteria as you're using for font size.

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
Thanks for the response hilfy.

I got through your first 3 steps and jotted down the Y and Height values. But in the Size & Position dialog box in CR2008, there is only one formula workshop link for X & Y and one formula workshop link for Width and Height.

Also, the help files specifically state that you can change the X and Width values by conditional formula, but no such mention is made of being able to do this with Y and height.
Is conditional formatting of Y and Height not allowed in CR2008?
 
Hmmm...I've never actually done it and I was working from memory when I wrote this - assuming there were buttons for Y and height. Drat! If that's the case, I don't thing there's any way to do what you're looking for.

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
You could try inserting another detail section_a that holds only the field that you are adjusting. Put the same field in detail_b along with other fields. Format the detail_a section to suppress except when the length is > 64. Format detail_a to underlay following sections. Align the detail_a field with the other detail_b fields by adjusting its position in detail_a. Suppress the detail_b field with a formula:

len({table.field}) <= 64

Note that since lengths are based on number of characters, you would never have a decimal result, and your current formula excludes the exact value 64.

-LB
 
Thanks LB for the suggestion, I will give it a try. Also, thanks for pointing out the issue in my # of characters formula, I didn't notice that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top