Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Basic functionality question from a novice Post Reply Post New Topic
Author Message
Dreaming
Newbie
Newbie
Avatar

Joined: 26 Jan 2010
Location: Canada
Online Status: Offline
Posts: 17
Quote Dreaming Replybullet Topic: Basic functionality question from a novice
    Posted: 26 Jan 2010 at 1:02pm
I've never used Crystal before and am far from a season programmer, but I find myself in a position where I need to work with this program due to manpower and time constraints.  I don't even have Crystal available to me yet and won't until later in the week, but I've identified a potential problem and want to hammer it out before I start working with it.

My question is that I know that I'll be working with a particular field in our database that contains two sets of information, but I only want to display one of those sets at any given time.  Is there a way in Crystal to only pull a portion of a field's data for display?

Sample data:

XYZ Cleaners | 230 Lakeside Drive

Can just "XYZ Cleaners" or "230 Lakeside Drive" be pulled and displayed on a report?  I'm familiar with similar functionality from working with Excel and Access, I just don't know if the same rules apply in Crystal.

Further to that, can a display field be created in my report that parses data from several database fields and combines it into one seamless text string? 

Sorry if my grip of Crystal's vernacular makes this unclear.

Thanks.

IP IP Logged
davejwhite
Newbie
Newbie


Joined: 19 Jan 2010
Online Status: Offline
Posts: 34
Quote davejwhite Replybullet Posted: 27 Jan 2010 at 3:51am
Hi there,
 
Yup - you can do this in a formula, using the Formula Editor. When you create a Formula, you can then use it on the report page just like a field.
 
In this case, you would
1. Find the character position (as a number) of the separating character
2. Extract all the characters to the left/right of that position
 
So it would look something like this:
Left( <<yourfieldname>>, InStr(<<yourfieldname>>, "|") - 1)
 
This gets all characters to the left of the 'pipe' character.
 
Right( <<yourfieldname>>, InStr(<<yourfieldname>>, "|") -+1)
 
This gets all the characters to the right of the 'pipe' character
 
Second question:
You can do this using concatenation. The 'concatenate' operator is a &. So if you create a formula looking something like this:
 
<<field1>> & <<field2>> & <<field3>> ...
 
you'll get the values from the fields 'seamlessly' butted up against each other. If you want separating spaces,
 
<<field1>> & " " & <<field2>> & " " &  <<field3>> ...
 
inside the concatenated " ... " just type anything you need to sit in between the values - in this case it's a space.
 
Good luck!
 
IP IP Logged
Dreaming
Newbie
Newbie
Avatar

Joined: 26 Jan 2010
Location: Canada
Online Status: Offline
Posts: 17
Quote Dreaming Replybullet Posted: 27 Jan 2010 at 6:55am
That's great.  I was hoping (and pretty much expecting) that it would be as simple as this, but I wanted to know before I actually got started.

Thanks so much for the reply.

Smile
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 27 Jan 2010 at 8:50am
I normally use the '+' signs to concatenate.  It is easier for me to find on the keyboard. :-)
IP IP Logged
davejwhite
Newbie
Newbie


Joined: 19 Jan 2010
Online Status: Offline
Posts: 34
Quote davejwhite Replybullet Posted: 28 Jan 2010 at 1:12am
Using + is no problem with a string and has the advantage of propagating nulls. For example if we have
 
"Name " + <<myNameField>>
 
if <<myNameField>> contained a Null, the whole concatenated string would become a Null
 
The problem with + is that if you use it on Numeric fields, it won't concatenate, it will add. So
 
12 + 25
 
Result is 37 not 1225
 
As long as you remember, it's not a problem
IP IP Logged
Dreaming
Newbie
Newbie
Avatar

Joined: 26 Jan 2010
Location: Canada
Online Status: Offline
Posts: 17
Quote Dreaming Replybullet Posted: 28 Jan 2010 at 6:36am
I'll keep that in mind.  Thanks again.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.