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!

How to suppress blank characters

Status
Not open for further replies.

PAULCALLAGHAN

Technical User
Sep 4, 2001
165
CA

I'm using CR version 8.5 and have two text fields that are 25 characters in length. They are not always used to their maximum space.

Is there a way to merge these two fields together without showing the blank spaces? I have limited space and I would like to present these fields as a single field on a report.
 
You can do 1 of 2 things:

One, you can add a text object to your report and then drag the 2 fields into it.
Second, you can create a formula to concatenate the 2 fields:
Code:
trim({table.field1}) + trim({table.field2})

~Brian
 
Forgot to add that depending where it is on the report, you may be able to put the 2 fields in there own section and then use the "Suppress Blank Section" option in the Section Expert.

~Brian
 
The third option might be to use a SQL Expression which would offload the processing to the database:

{fn RTRIM(`table`.`field1`)}+{fn RTRIM(`table`.`field2`)}

Assumes only the right trim required, add the LTRIM also if required.

-k
 
Excellent! The trim function.

I have another part to my question though. The person who inputs to one of these fields will place "??" at the right-most end of the field. It will not always be in the same place everytime though, and it is only done in certain situations.

How can I extract this "??" from my merged result, that uses the Trim function?

Is there a way to extract certain characters?
 
If you need to remove the "??" then you can do that with the replace function.
Code:
Replace({@MergedResult},"??","")


~Brian
 
Hi,
If you want to eliminate the ?? from your concatenation,
use a InStr to find the first occurance of the '?' and then create a substring that stops before it gets to that char.
Try something like:
Code:
trim({table.field1[1 to (Instr({table.field1,"?") -1)]) +
trim({table.field2[1 to (Instr({table.field2,"?") -1)])
You can also a function ( as recommended by -k) :
Depending on the database, it would use InStr and SubString functions - the exact syntax is Database specific.
[profile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top