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!

text box size 2

Status
Not open for further replies.

MadCatmk2

Programmer
Oct 3, 2003
145
GB
hi all

Crystal 9 with Access 97 database

I would like to know if something like this is possible:

At present i have a report which just has some data shown on the details section. There is a text box which has its coulour set depending on the value of a formula. This text box is the full height of the details section and so presents varying colours next to each record depending on when a patient was last seen. Red at the top, then orange and finally green.

At the moment there is no gap in the colours when the report is output. I have just added a field {Contact_Type} that will not necessarily fit on one line and have had to set the can grow option so that it will use as many lines as required to display the contents.

The problem is this:
At any record where the {Contact_Type} runs on to more than one line there is a gap appears in the colour as that field will not grow to the same size as {contact_type}.

Is there any way that i can set the couloured filed so that it grows to the size of the {contact_type} field.

Thanks in advance.
 
You could create the following formula and place it in the text box, and format the text box to "Can Grow":

if len({contact.type}) > 5 then
replicatestring(chr(13),int(len({Orders.Ship Via})/5)+1)

Change the "5" to the number of characters returned in {contact.type} before the field wraps. For this to work consistently, you would have to use a non-proportional font like Courier for {contact.type}.

-LB
 
Hi LBass

Thanks for that suggestion. Sounds like a really good idea, i'm going to go try that just now.

Thanks for your help.
 
I think the best way to handle this is through formulas for both fields.

Lets assume 40 characters per line, but you change that value in the first formula.

Create 1 formula to handle the contact_type field and use it in the details section:
Code:
WhilePrintingRecords;
local numbervar line_len := 40; //change line length here
local stringvar input := {table.Contact_Type};
local stringvar output;
numbervar x;

for x := 1 to (int(length(input)/line_len) + 1) do
(
    if length(input) < line_len then
        output := output & input
    else
        (
            output := output & left(input,Instrrev(input,space(1),line_len)) & chr(13);
            input := mid(input,Instrrev(input,space(1),line_len)+1);
        );
);
output

Create a second formula in place of the text box:
Code:
whileprintingrecords;
numbervar x;
local numbervar y;
local stringvar result := ""; //if you need a value displayed, put it where the quotes are

for y := 1 to x do
(
    result := result & chr(13);
);

left(result,length(result)-1)

You will need to apply the color formula to this second formula.

Also, make sure you set the Can Grow property for each property and only make the height of the 2 formulas 1 line.

Let me know how it works out for you.

~Brian
 
I like lbass's approach and I think his formula would simplify my second one:

Code:
whileprintingrecords;
global numbervar x;
replicatestring(chr(13),x-1)

If font isn't a big deal, then lbass's is the cleanest, and fastest way to go. If font is an issue, they my approach should work for you.

~Brian
 
Brian, LB

Thanks so much for your help. Both of your suggestions worked great. I am going to go with Brian's suggestion (no offence to your suggestion LB), only as it is not specific to font choice and i'm not yet sure what the final font will be.

Thanks to the both of you.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top