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

Selecting one value from a field that allows multiple values

Status
Not open for further replies.

campsb

Technical User
Sep 27, 2002
4
US
I need to select one value from a field that allows multiple values in the field for each record. For example, the field contain, A,B,HR,FIN. I need only the records that contain HR. Which functions works for this?

 
--------------------
"HR" IN {your_field}
--------------------

hth,
- Ido CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
It's inefficient, but in the record selection formula use:

instr('HR', {table.Field}) > 0

If you're using a SQL Server database (or any SQL compliant database and connectivity), you can create a SQL Expression to create a test of the condition and filter accordingly in the record selection formula, offloading the work to the server, as in the following SQL Expression which I named instrtest:

CHARINDEX('HR', Table."multifield")

Then in the record selection formula use:

{%instrtest} > 0

This will limit the rows from the database.

-k kai@informeddatadecisions.com
 
Ido offered a nice alternative to my first suggestion, but again, this won't be passed to the database, it will be processed by Crystal (slower performance).

But if you opt for that approach, use his.

-k kai@informeddatadecisions.com
 
Thanks, now for an added feature. If I want to only show the one code I am pulling how do I suppress the remaining codes in that field?
 
Rather than suppress the others, just use "HR" in a text object.

Since the record selection has already qualified them all as HRs, just use HR as text or in a formula.

The means to determine if something contains HR in it would be something like:

if "HR" IN {your_field} then
"HR"
else
"Nope..."

-k

kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top