Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Passing array in the parameter Post Reply Post New Topic
Author Message
pritamdas24
Newbie
Newbie
Avatar

Joined: 30 Jul 2007
Location: India
Online Status: Offline
Posts: 24
Quote pritamdas24 Replybullet Topic: Passing array in the parameter
    Posted: 31 Jul 2007 at 6:39am
I have one Parameter  in a  report and it is static .  The user can enter values in the parameter using comma separator. 
  
How to write the Syntax in "Record selection formula editor"? 
 
e.g
My command will be like this
 
select col1,col2,col3 from tab1 where param_col in('val1','val2','val3')
 
i am using one parameter in the report
 
Please let me know how to write in the Record selection formula editor.
Regards
Pritam
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 31 Jul 2007 at 9:59am
Hi Pritam,

This is an excellent question and I decided to add it to my book in the "Best of the Forum" section. Thanks! 

You need to use the Split() function to split the string into an array. And then us the In operator to test if the field in is the array. Here is an example:
CStr({Customer.Customer ID},"#") IN Split({?Customers},",");

There is two important things to be aware of: I converted the number to a string using CStr() because the Split() function returns an array of strings. If the data field is a string, then you don't have to use this function at all. The second thing is that IF you are converting it to a number, then the Cstr() function has to return the number without any decimals in it. That is why I used "#" as the second parameter for the CStr() function.

Oh yeah - the user shouldn't put quotes around the individual items. Just separate them with commas like:

1, 5, 7

I hope this helps. Now I need to go write this up for the book!




Edited by BrianBischof - 31 Jul 2007 at 10:01am
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
pritamdas24
Newbie
Newbie
Avatar

Joined: 30 Jul 2007
Location: India
Online Status: Offline
Posts: 24
Quote pritamdas24 Replybullet Posted: 31 Jul 2007 at 10:29pm
Thanks Brian For all the help
Regards
Pritam
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.