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

Need help with Record Selection Formula - LIKE operator

Status
Not open for further replies.

ctwilliams

Programmer
Feb 15, 2002
86
US
We have a "version" field in our database that contains values similar to the following:

V6.00.01.05
V6.00.03.00
V6.00.03.01

I have setup my record selection formula using the LIKE operator so that users can run the report for
V6.00.03.* and it will return V6.00.03.00, V6.00.03.01, etc.

I now need to allow users to enter multiple values, eg. V6.00.01.*, V6.00.03.*. I tried this but it didn't work:

{DB.Version} LIKE ["V6.00.01.*", "V6.00.03.*"]

So far my parameter is still a single-value parameter; I have not set it up to be a multiple because I didn't want to have to loop through an array.
 
As part of the prompting text ask the users to include an asterisk at the end of each choice, then just use:

{db.version} like {?versionparm}

Will create a series of OR Like statements.

To check the SQL generated use Database->Show SQL Query

-k
 
I tried that but it didn't work.

I entered the following values for my {?versionparm}:

Code:
V5.53.19*, V5.53.21*

The following is in my record selection formula:

Code:
{db.version} like {?versionparm}

No results are returned when I run the report.

Here is the SQL statement that was generated:

Code:
SELECT DISTINCT 
    table1.Field1, table1.Field2, table1.version
FROM
    db.dbo.table1
WHERE
    table1.version LIKE 'V5.53.19%, V5.53.21%'
 
How about a slightly different approach:

{DB.Version} startswith ["V6.00.01.", "V6.00.03."]

Or,
{DB.Version} startswith {?parm}

...where the entry is in the form of "V6.00.01."--you could probably eliminate the final period, too.

I have never been able to get "like" to work with multiple-value parameters, although that might just be me. I think the above should work for you though.

-LB
 
try :

{db.version} like join(split({?versionparm},",")," or {db.version} like ")

Let me know if successfull

Django
 
You misubderstood my intent and how Crystal works.

Make the parameter a multi and try my method, it works.

No need to overcomplicate any of this nor second guess how Crystal works.

-k
 
Thanks synapsevampire! I misunderstood you the first time. Once I made my parameter a multi and used

{db.version} like {?versionparm}

in my selection formula, it worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top