Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Issue with InStr and field with spaces Post Reply Post New Topic
Author Message
jennifer_falcon
Newbie
Newbie
Avatar

Joined: 15 Jan 2009
Online Status: Offline
Posts: 35
Quote jennifer_falcon Replybullet Topic: Issue with InStr and field with spaces
     Posted: 23 Aug 2011 at 5:24am
Good Day,

I am having trouble with the InStr function in Crystal.

I am using Crystal Report s XI.

Here are my fields in my report:

Field Headers
Company                   Ticket Number                Company_Multiple
xyz company              C123456                        abc company def company                                                                                ghi company jkl company

The Company Multiple field is a memo field.

The data in the field may have a number of spaces in between each company entry. In some cases, the field data could look like this:

abc company             def company ghi company            jkl company

I created a formula called CompanyAffected
============================================
numberVar i := 0;
numberVar j := 0;
stringVar out := " ";
stringVar array test := split({cm3rm1.company_multiple}, chr(10)+chr(13) );
i := ubound(test);
if i > 0 then
   for j := 1 to i step 1 do
        out := out + UpperCase(test[j]) + " ";
out
============================================

I then have a parameter called ?My Parameter. This parameter would allow a user to type in a Company name to get all the Ticket Numbers where the Company is in the company_multiple list.

In my record selection, I have put in:
==============================================

InStr ({@CompanyAffected},(" " + Uppercase({?My Parameter}))) <> 0
===================================================

My problem is:

In the case where I the company_multiple look like this:

abc company


def company
ghi company


jkl company

I can choose the parameter of abc company and the tickets will come back.

But, if I choose the company def company or jkl company, the records won't appear. It's like my formula will only see the company if it is the first entry in the company_multiple list. How can I get the tickets for a company if they are not the first entry in the company_multiple list?

Thanks,

Jennifer



IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Aug 2011 at 6:14am
not quite sure why you are splitting it into an array. If you are just typing in one company name and checking it against a field you can use the instr option directly at the field and make it case insensitve...
 
instr({cm3rm1.company_multiple}, {?My Param},1) > 0
IP IP Logged
jennifer_falcon
Newbie
Newbie
Avatar

Joined: 15 Jan 2009
Online Status: Offline
Posts: 35
Quote jennifer_falcon Replybullet Posted: 23 Aug 2011 at 7:15am
Smile

Thanks DBlank. That worked perfectly. You're the best!!Clap

I have no idea why the original developer of this report designed the formulas that way.
IP IP Logged
jennifer_falcon
Newbie
Newbie
Avatar

Joined: 15 Jan 2009
Online Status: Offline
Posts: 35
Quote jennifer_falcon Replybullet Posted: 24 Aug 2011 at 9:57am
Sorry to re-open this issue.

The information you gave me worked to find the company parameter in my Memo field. What I forgot to ask was:

How can I format the field to remove the spaces and instead, replace them with commas?

The Company Multiple field is a memo field. The data can look like this:

abc company


bcd company
def company


efg company

When I display the field, I want the data to look like (I want to remove all the extra spaces and then replace them with commas):

abc company, bcd company, def company, efg company

Thanks!
IP IP Logged
jennifer_falcon
Newbie
Newbie
Avatar

Joined: 15 Jan 2009
Online Status: Offline
Posts: 35
Quote jennifer_falcon Replybullet Posted: 30 Aug 2011 at 10:29am
Ok, I have found a solution that should work for me.

If you go to:
1) Format Field
2) Paragraph Tab
3) Click the drop-down menu for Text Interpretation
4) Change the Text Interpretation to HTML text

The field now looks like
abc company bcd company def company efg company

It doesn't have the commas, but it looks so much better!

Hope this helps someone else out.
IP IP Logged
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