Solved

Parameter in Query (SQL Server Report Builder) not working?

Posted on 2011-02-15
4
685 Views
Last Modified: 2012-05-11
I'm running a rather simple query with a parameter, so that in a report, the user can enter the year and a chart will display data from said year.
If I hard-code in the year, like this:

SELECT 
"All Parts" AS `Product Part Number`, 
Month(`DateReworked`) AS Mo, 
Year(`Datereworked`) AS Yr,
Avg(tblReworkRecords.DaysToRework) AS AvgOfElapsedDays

FROM 
(`Product part number List` 
INNER JOIN `Shop Order List` 
ON `Product part number List`.`Product Part Number` = `Shop Order List`.`Product Part Number`) 
INNER JOIN tblReworkRecords 
ON `Shop Order List`.`Shop Order Number` = tblReworkRecords.ShopOrderNumber

WHERE 
((Year(tblReworkRecords.Datereworked) = 2010)) 
AND 
(((tblReworkRecords.DateReworked)>'1/1/2004'))

GROUP BY Month(`DateReworked`)

HAVING (((Avg(tblReworkRecords.DaysToRework)) Is Not Null))

Order BY `Product Part Number`, Mo, AvgOfElapsedDays

Open in new window


I get exactly what I am looking for for 2010 (12 rows, 1 for each month)

However if I used the EXACT same code, only where it says ((Year(tblReworkRecords.Datereworked) = 2010)), I change it to ((Year(tblReworkRecords.Datereworked) = @Year)) , and run the query (it prompts me to enter a year for the parameter, and I type in 2010), I get absolutely no rows of data, none at all.

Does anyone know what I am doing wrong or why I am getting no data?

Thank you in advance.
0
Comment
Question by:AAI_Development
  • 3
4 Comments
 
LVL 5

Expert Comment

by:robertg34
Comment Utility
Double check your parameters and make sure @Year is mapped correctly to that input box.  Also make sure the parameter is data-typed correctly.  I'm assuming its a number field.  

It might be helpful to put a default value in the parameter as well.  
0
 

Author Comment

by:AAI_Development
Comment Utility
Tried every data-type, tried a default value....nothing...
0
 

Accepted Solution

by:
AAI_Development earned 0 total points
Comment Utility
Figured it out...apparently you cannot do this if you are using ODBC, which I am.
0
 

Author Closing Comment

by:AAI_Development
Comment Utility
Was correct, but I have non-compatable data source.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Hi, I have heard from my friends that it’s not possible to create Label Printing report using SSRS. I am amazed after hearing this words not possible in SSRS. I googled lot and found that it is possible to some of people know about the Report Bui…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

16 Experts available now in Live!

Get 1:1 Help Now