Friday, September 26, 2008

Radio Buttons for Reporting Services Reports

Create table
create table tSurvey(CustomerName varchar(30) NOT NULL,WouldRecommend varchar(2) NULL)
Insert Values in the table
INSERT INTO tSurvey VALUES ('Trent Miesner', 'A')
INSERT INTO tSurvey VALUES ('Bill Gates', NULL)
INSERT INTO tSurvey VALUES ('George Bush', 'SA')
INSERT INTO tSurvey VALUES ('Bill Clinton', 'SD')
Select values from table
SELECT
tSurvey.CustomerName,
CASE tSurvey.WouldRecommend WHEN 'SA' THEN 'l' ELSE 'm' END AS WouldRecommend_SA,
CASE tSurvey.WouldRecommend WHEN 'A' THEN 'l' ELSE 'm' END AS WouldRecommend_A,
CASE tSurvey.WouldRecommend WHEN 'SD' THEN 'l' ELSE 'm' END AS WouldRecommend_SD
FROM tSurvey
ORDER BY tSurvey.CustomerName
Creating the Report
Now we can create our report. We’ll drag the WouldRecommend_SA, WouldRecommend_A, and WouldRecommend_SD fields onto the report. Then, we’ll use the Properties window to change the font to “Wingdings.” The letter “l”, rendered as a Wingding, becomes a selected radio button while “m” is a non-selected radio button.
Make sure you put the right data field in the right place. WouldRecommend_SA goes in the Strongly Agree column, _A in the Agree column, and _SD in the Strongly Disagree column.
Once we change the font, it scrambles the field name in Layout view...
...but it has the desired effect once the report is run.
The Character Map applet (Start, Programs, Accessories and System Tools) is where we determined that “l” and “m” represent a selected and non-selected radio button respectively. Feel free to experiment with other icons.
Conclusion
Producing radio buttons and check boxes in Reporting Services isn’t as simple as dropping a control onto the report. Fortunately, the simple steps shown in this article and in Check Boxes for Reporting Services Reports provide an easy way to achieve the desired result.

No comments: