Tips and Tricks
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Tips and Tricks
Message Icon Topic: Multiple values question Post Reply Post New Topic
Author Message
pkfox
Newbie
Newbie


Joined: 03 Jan 2015
Location: United Kingdom
Online Status: Offline
Posts: 6
Quote pkfox Replybullet Topic: Multiple values question
    Posted: 07 Sep 2015 at 8:53pm
Hi all ,If I have a multiple value parameter in my report ( I have several of them ) what is the preferred method of filtering the output using the array ? I'm a bit confused having read about Join and Split et al

TIA


Edited by pkfox - 07 Sep 2015 at 8:54pm
We can't stop here, this is bat country. Hunter S Thompson RIP.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 08 Sep 2015 at 9:35am
You don't have to do anything to it. In the Select Expert, select the field you want to match to, then "is in", then the parameter. Crystal will handle the rest.

-Dell
IP IP Logged
pkfox
Newbie
Newbie


Joined: 03 Jan 2015
Location: United Kingdom
Online Status: Offline
Posts: 6
Quote pkfox Replybullet Posted: 08 Sep 2015 at 7:18pm
Originally posted by hilfy

You don't have to do anything to it. In the Select Expert, select the field you want to match to, then "is in", then the parameter. Crystal will handle the rest.

-Dell


Hi and thanks for replying but I need to know how to do it in code as it's not as simple as just filtering on a record level - I think I can achieve it by using join and split though
We can't stop here, this is bat country. Hunter S Thompson RIP.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 09 Sep 2015 at 4:00am
Ok, for a multi-value parameter you need to create one ReportParameter.SingleValue for each value in the multi-select list and add each of them to the parameter. Here's some sample code that I found:

if(boReportObjects.Count > 0)
{
    boReportObject = boReportObjects[1];
    boReport = (Report)boReportObject;
    //Grab the parameters off of the report object
    boParameters = boReport.ReportParameters;
    //Loop through all parameters, checking for parameter type
    foreach(ReportParameter boParameter in boParameters)
    {
        if(boParameter.SupportsRangeValues == true)
        {
            //set the Range parameter value
            //in this case we are doing a number range
            boParamValue = boParameter.CreateRangeValue();
            boParamValue.RangeValue.FromValue.Value="10";
            boParamValue.RangeValue.ToValue.Value = "20";
            //set whether boundries are inclusive or exclusive
            //of the range values
            boParamValue.RangeValue.IncludesLowerBound = true;
            boParamValue.RangeValue.IncludesUpperBound = true;
            boParameter.CurrentValues.Add(boParamValue);
        }
        else
        {
            switch(boParameter.ValueType)
            {
               case CeReportVariableValueType.ceRVBoolean:
                 boParamValue = boParameter.CreateSingleValue();
                 boParamValue.SingleValue.Value = "true";
                 boParameter.CurrentValues.Add(boParamValue);
                 break;
               case CeReportVariableValueType.ceRVCurrency:
                  boParamValue = boParameter.CreateSingleValue();
                  boParamValue.SingleValue.Value = "33333";
                  boParameter.CurrentValues.Add(boParamValue);
                  break;
              case CeReportVariableValueType.ceRVDate:
               boParamValue = boParameter.CreateSingleValue();
               boParamValue.SingleValue.Value = "Date(2005,08,19)";
               boParameter.CurrentValues.Add(boParamValue);
               break;
              case CeReportVariableValueType.ceRVDateTime:
               boParamValue = boParameter.CreateSingleValue();
               boParamValue.SingleValue.Value = "DateTime(2003,8,6,0,0,0)";
               boParameter.CurrentValues.Add(boParamValue);
               break;
              case CeReportVariableValueType.ceRVNumber:
               boParamValue = boParameter.CreateSingleValue();
               boParamValue.SingleValue.Value = "10524";
               boParameter.CurrentValues.Add(boParamValue);
               break;
              case CeReportVariableValueType.ceRVString:
               boParamValue = boParameter.CreateSingleValue();
               boParamValue.SingleValue.Value = "USA";
               boParameter.CurrentValues.Add(boParamValue);
               //this parameter can accept multiple values
               boParamValue = boParameter.CreateSingleValue();
               boParamValue.SingleValue.Value = "Canada";
               boParameter.CurrentValues.Add(boParamValue);
               break;
              case CeReportVariableValueType.ceRVTime:
               boParamValue = boParameter.CreateSingleValue();
               boParamValue.SingleValue.Value = "Time(12,15,15)";
               boParameter.CurrentValues.Add(boParamValue);
               break;
          }
      }
}


-Dell
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.031 seconds.