Solved

How do I use a multivalue parameter on SQL Server command window in Crystal Reports 2008?

Posted on 2011-09-13
5
233 Views
Last Modified: 2012-06-27
Hello,

I'm using a SQL command window in Crystal 2008 as the data source for my report. I've checked the box in the command parameter window to "allow multiple values" but I'm getting an error message when I use mulitple parameters.

Below is a simplified version of my sql code:

declare @Company as varchar(4);
set @Company = {?Company}   ----  {?Company} is the multivalue parameter

select c.company_id, c.description, c.ownership_pct
from company c
where c.company_id = {?Company}


Do I need to change the syntax of my query when using the "allow muliple values" feature? I've tried changing the code to "where c.company_id in {?Company}" but I continue to get the attached error message.

Any ideas on how to get past this error?

Thanks!
David
 Crystal Reports Error Message
0
Comment
Question by:dking_wri
  • 2
  • 2
5 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 400 total points
ID: 36530857
The multiple values is for parameters you build through the ADD PARAMETER button in the command window.  It is not for parameters you declare in that way.

Why are you using the SET, that is declaring a parameter in the command.  Try deleting that line

mlmcc
0
 
LVL 77

Assisted Solution

by:peter57r
peter57r earned 100 total points
ID: 36530908
I would use IN rather than =
0
 

Author Comment

by:dking_wri
ID: 36531844
Hi mlmcc,

I'm using SET as I have repeated the variable multiple times in the actual code. But I think I'm following your question. Maybe I should replace every instance of the @company with the Crystal equivalent  {?Company}. Let me try that and I'll get back to you.

Hi peter57r,

I did use the IN function when I first encountered the error. I'll try this again in combination with mlmcc comment and get back to you.

Thanks again,
David
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36532351
You declared @Company s a VARCHAR(4), it can't have multiple values.

mlmcc
0
 

Author Closing Comment

by:dking_wri
ID: 36532382
Thanks for the help. I replaced my declared SQL variable with the Crystal Parameter and it worked.

I used the IN statement again, but this time I removed the parenthesis and was able to get the report to run as expected.

Thanks again for your time and input!!

David
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now