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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keeping Text Together 1

Status
Not open for further replies.

sjp0362

Technical User
Joined
Oct 23, 2004
Messages
48
Location
US
Our specification sections used to be a 5-digit number without any spaces (e.g. 02100). Recently the industry (at the national level) has changed these specification sections to a 6-digit number with spaces (e.g. 02 10 05). Does anyone have any idea of how I can keep this 6-digit number with spaces together when it prints out of our data base using Crystal Reports? (I know how to keep together if I use programs like MS Word, and WordPerfect--but I haven't been able to find any way when using a database.)
 
First, it's not a number if it starts with a 0, it's a string.

Try posting technical information:

Crystal version
Database/connectivity
Example data (show what's in the field and it's data type)
Expected output

Saying keep together is vague, we can only guess at what you mean by that.

-k
 
You're right. I didn't give enough information.

Crystal Reports Version 9.2.

Database Program name is Viewpoint with ODBC (RDO) connection.

Database program has various text fields in which I include the eight digit string (e.g. "02 10 05") as part of the paragraph of text I'm entering.

Since I have various reports that include this text field and since the width of the field varies within my reports, there are times when this string gets broken up between two printed out lines (part is at the end of one line with the remainder being at the beginning of the next line). I don't want this eight digit string to ever get broken between the two lines if possible.

The only solution I've been able to come up with so far is to eliminate the spaces between the numbers of the string.

Hopefully this makes sense.
 
The obviou solution is to make the field wide enough so that it can always display it in it's longest state.

If you don't have the space, you might try programatically changing the font size based on the fields length.

Right click the field->Format Field->Font->X2 next to size and place:

if len(trim({table.field})) > 6 then
8
else
10

So it will shrink as a resultof being a smaller font when it's a longer field.

-k
 
Some of my text fields may contain up to 500+ characters, so I don't see that as a possibility. In MS Word and in WordPerfect I can enter what they consider a "hard space" (which is basically a character that is blank but acts like a letter or number). I wasn't sure if databases had some way of entering a "hard space" character.
 
What happened to it containing 8 characters with spaces in them?

You need to supply real examples of what's in there, it lept from 8 characters to 500.

Anyway, to build a carriage return, you use chr(13), as in:

"Hi" + chr(13) + "there"

Then you would right click the formula and select format field->Can Grow.

I've no idea what the field contains or I'd try to help further.

-k
 
The overall text field may contain 500+ characters, so I don't want the font size to change as the font size would get too small. I do have my field set up so it can grow. Within the text field however, I may have a reference to the specification section 02 10 05, and I want those eight characters within the 500+ to work more as one entity (or as one word).

Sample of Information within Text Field:
Per Section 00 23 00, Site Paving Contractor is to provide all field measurement and lay-out work necessary for the completion of the contractor’s work. Timely submission of insurance certificates, schedule of values, shop drawings, product data, samples and mockups, as specified. Cooperation with other trades in the completion of their work. Cooperation with the Owner’s construction manager in the use and management of the site and in the coordination of work with other trades. All freight and delivery charges for delivery of materials. The receiving and off-loading of all materials associated with the contractor’s work. Storage on-site of materials shall be approved by the construction manager and coordinated with other trades. The establishment and the enforcement of safety programs as outlined in the specifications, and housekeeping and final clean-up. Comply with all applicable specification sections including Section 32 10 05 and related traffic sign.

I would like "32 10 05" within this paragraph to be together on the same line--I don't want part of it to be on one line and part on the next line.
 
Purdy tricky in Crystal, but it can be done.

Curious how you would elegantly do so in MS Word...

Final clarification, will it always be preceded by the word Section?

That makes it much easier.

And wouldn't you also want to make sure that 00 23 00 is all on one line? I don't understand why it's only the latter section number.

-k
 
MS Word. Ctrl+Shift+Space Bar creates a hard space, so type "02(Ctrl+Shift+Space Bar)10(Ctrl+Shift+Space Bar)05". These eight characters will never separate between two different lines.

You are correct that in my sample, I would like the 00 23 00 to stay together also.

For clarification, I cannot say that these will always be preceded by the word Section, as sometimes we may reference numerous sections together (e.g. Sections 00 23 00 and 32 16 01). And as if to make matters more of a challenge, some sections may be broken down a little deeper with 11 characters (e.g. 00 23 16.05).
 
Ahhh, you meant as you typed it you could do so, not that you could readily code MS Word to handle numbers with spacing, you made it sound as if you were using some pattern matching in MS Word...

OK, that clarification does toss in a few coefficients.

So it's going to be kinda slow as every text field needs to be reassembled.

whileprintingrecords;
stringvar input2:={table.field};
stringvar array input:=split(input2," ");
stringvar output:="";
numbervar counter;
For counter := 1 to ubound(input) do(
if counter <> ubound(input)
and
isnumeric(input[counter]) and isnumeric(input[counter+1])
then
Output:=Output+input[counter]+chr(160)
else
Output:=Output+input[counter]+" "
);
output

So this kinda cheats as all it really does is replace the space with a hard space if the current "word" is a number, an the next "word" is also a number. We can't really determine that it's a section, but this rule should work fine as it's rare when text has 2 numbers together.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top