The Altoona IT Group

A knowledge sharing and networking group for Altoona, PA area IT professionals.
Welcome to The Altoona IT Group Sign in | Join | Help
in Search

Altoona IT Group

Printing Labels with SQL Server Reporting Services

During the course of a current client project, the need arose to convert a report from an older system to the new implementation.  The requirements were simple, print Avery style labels on 8.5" x 11" paper.  What was the delivery mechanism of choice?  SQL Server Reporting Services.  After searching the web for some info on this, I found some answers that were pretty lacking in details so I decided to document the process for future developers.

This project is not able to be accomplished utilizing the end user ‘Report Builder' product.  You will need to use the Visual Studio Report Designer.  I will assume that if you have come here, you already know how to create a new report in Report Designer.  

Before you start working on the report you will need to determine the following specifications. 

How many columns of labels do you require? 

What is the width and height of a single label?

What are the margins of the label sheet?

Our example will use 3 columns of labels, each label measuring 2" high by  2.5" wide, with .5" margins at the sides and top.

Once you have determined these things, create a blank report in Visual Studio Report Designer.

Go to the Layout tab and open the properties for the report:

SSRS Report Properties

Go to the layout tab and set the margins and page size to match the whole label sheet size and margins.

SSRS Report Layout

Once you have made these settings changes, you are ready to start adding controls to the report.  Go to the toolbox and drag 1 List control for each column.  (An lternative method would be to use one list control and set the column number in the properties above, but I have found that doing it this way gives you more control over label spacing.)

SSRS Report List Control

Set the controls width and height to match the size of one label on the report.  Align the List controls in a single row across the page, taking the spacing on the physical sheet into account.

SSRS Report List Controls

Next , create the dataset that will supply data to the report.  The one critical criteria for your dataset is that it contain a field that will give the rows ordered numbering starting at 1.  Check out this article from Microsoft on building a rank field directly into your dataset query: http://support.microsoft.com/kb/186133

Once you have created your dataset,set the dataset name and visibility expression for each list control so that it pulls the correct rows from the data.

SSRS Report List Dataset

SSRS Report List Visibility Expression

The expression will need to be different for each list control.  Here is a breakdown of the expression:

=IIF(Fields!Rank.value mod 3=1,true,false)

This expression uses the IIF function to set the visibility for that particular list control to true or false based on the Rank field of my query.  The modulus returns the remainder after dividing the rank by the number of columns on the page, in my case, there are 3 columns.  The first column will check if it equals 1, the second column will check for 2, the final column will check for 0.  If there were four columns, the third column would check for 3 and the last column for 0.  So, here are my three expressions, from left to right

 

=IIF(Fields!Rank.value mod 3=1,false,true)

=IIF(Fields!Rank.value mod 3=2,false,true)

=IIF(Fields!Rank.value mod 3=0,false,true)

***- An alternate method was posted by abbi below -- see the comments

Once this step is finished, you will need to add controls such as text boxes to your list controls and assign fields from your dataset to them.  The easiest way to go about this is to design the first list control's content, and then copy the content inside of the list control and paste it into each of the remaining controls.  Below is an example of setting the properties for a text box control within a list control.

 

SSRS Report Text Box Properties

Once you have finished the layout, preview and print your labels.  You may need to tweak your margins or your layout a little bit to get it perfect. 

Congratulations!  You should now be able to print your labels with SQL Server Reporting Services.

Comments

 

Dave Carmany said:

Excellent article!  If you need a source for the labels check out http://www.onlinelabels.com.  The selection is much larger than the office supply store and the pricing is about 40%-90% less than Avery brand labels.  

December 14, 2007 4:37 AM
 

Alex Flores said:

I am also doing a 3 column design but seem to still get duplication

is this the correct code for the lists visibility?

=IIF(Fields!Rank.value mod 3=1,true,false)

=IIF(Fields!Rank.value mod 3=2,true,false)

=IIF(Fields!Rank.value mod 3=0,true,false)

I appreciate your time.

Alex Flores

December 17, 2007 9:02 AM
 

Lee Dively said:

Hi Alex,

In your datasource, what field are you using to count records?  

When you preview your data, is the field numbering unique and incrementing by 1 per record?  If you want to, IM me through the AIM widget on the page here and I will try to help you out.

December 17, 2007 9:54 AM
 

Doug Lundin said:

I am doing the 3 column design and when I try to run it, I get the error

The hidden expression for list 'list3' contains an error.  Input string was not in a correct format.

Thanks,

Doug

December 19, 2007 8:40 AM
 

Abbi said:

Hi Lee, It was a great article. I tweaked it a little bit as per my need. And instead of using RANK I used the (RowNumber("DatasetName")) instead.

December 19, 2007 9:23 AM
 

Bill said:

Good stuff -

BUT - You may want to swap true,false if you want this to work.

change this...

=IIF(Fields!Rank.value mod 3=1,true,false)

to...

=IIF(Fields!Rank.value mod 3=1,false,true)

The boolean value applies to the hidden property so in column 1 where mod 3=1,  values 1,4,7..., set the HIDDEN property to false.

December 24, 2007 5:10 AM
 

avery labels said:

Pingback from  avery labels

April 4, 2008 4:33 AM
 

Mike said:

Fantastic post, saved me hours.  I was very apprehensive to attempt labels with RS but this made it child's play.  

Thanks agian  

April 28, 2008 3:02 PM
 

Nik said:

Hi

Do you know if it is possible to enable the "Print Layout" to be displayed by default in the webinterface

I'm using RS 2005 in integrated mode, but there is no option for Print Layout preview.

Is there an option to force this in the report somehow, so when the user runs the report all the columns are displayed rather then the first one only.

The user still can page through the records but each collumn is displayed on a separate page and this is kinda annoying (unless the report is exported or printed in which case the columns are displayed as defined)

May 29, 2008 4:23 PM
 

Lee Dively said:

@Nik

I will need to look into this for you.  My particular report / deployment displays all of the records on the page online.  When you say integrated mode, are you referring to a Sharepoint integration?

June 4, 2008 7:33 AM
 

avery labels said:

Pingback from  avery labels

July 15, 2008 12:06 PM
 

avery labels said:

Pingback from  avery labels

August 25, 2008 1:50 PM
 

Erics Blog said:

I needed to create a report that should be used for printing labels, but this kind of layouts is not

November 21, 2008 8:22 AM

About Lee Dively

Microsoft Certified Technology Specialist   Microsoft Certified Business Management Solutions Specialist
I am a Microsoft Certified Professional who has been working as an application developer for over 9 years. I started out as a Computer and Automated Systems Repairer in the United States Army. From there I moved to Accuweather, Inc. as a Computer Applications Analyst / Programmer. Finally, I began working for Sound Computer Services, which is now known as Empower Business Solutions, a Microsoft Gold Certified Partner dealing in Microsoft Dynamics GP as well as custom software solutions. I have extensive experience in developing and modifying software on the Microsoft platform. Some of my skills include:

Microsoft SQL Server 2000 / 2005 administration and development including extensive knowledge in advanced SQL query development, Reporting Services, Analysis Services, and SSIS development.

Microsoft .Net Framework vs. 1.0,1.1 and 2.0 knowledge to include extensive web and winforms application development utilizing VB.Net and C#.

HTML, Javascript, CSS, and XML.

Microsoft Access 2000 / 2003 / 20007 development utilizing SQL backends.

Microsoft Windows Sharepoint Services v 3.0 and MOSS 2007 implementation and development.

Windows Server 2000, 2003 and Windows XP operating systems.

Microsoft Dynamics GP 10 Installation and Configuration, development utilizing Extender and Modifier w/ VBA, reporting utilizing Report Writer and SQL Server Reporting Services

This Blog

 
AddThis Social Bookmark Button

Syndication

Archives

Powered by Community Server (Non-Commercial Edition), by Telligent Systems