Solved

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

Posted on 2011-09-13
5
245 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 101

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 101

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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 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