0

I am working on a crystal report. Now I added a new parameter for CustomerId so that the report result can be filtered according to that.

In the interface we can select multiple customers, so the values will be something like

strCustomerid = '1,2'; // 1 & 2 are customer ids

If I select only one customer the filtering works perfect, but when I select multiple its not.

I tried something like below code in Crystal Report record selection formula

{ihCustomerId} IN {?strCustomerid} 

Then I get the error an integer is required here, so i had to convert it into integer, I think thats where the mistake happen.

{ihCustomerId} IN ToNumber ({?strCustomerid})

Now if I select one customer it works perfectly, but on multiple its showing no result.

What is wrong here? how can I correct this? please help.

J M
  • 396
  • 6
  • 23

2 Answers2

0

What about the solutions here, I'm pretty sure they can help you

Find text in string with C#

cheers, es

Goozo
  • 910
  • 2
  • 11
  • 28
0

Your incoming {?strCustomerid} appears to be a string, with values separated by a comma. The field in the data you are trying to select from appears to be a number {ihCustomerId}, so you'll have to first separate each element of {?strCustomerid} then convert {ihCustomerId} to a string to then do the comparison. This should work for you (in Crysta Syntax):

CStr({ihCustomerId},0,"") IN Split({?strCustomerid},",")

CStr converts to a string, and the parameters ensure the number is formatted correctly. Split will split the incoming parameter into distinct elements within an array, using a comma as the character to split upon.

Dan
  • 56
  • 4