Friday, August 11, 2017

Presenting addresses in SSRS

If you need to print forms in SQL Reports I have an easy way to do it so that blank address lines are removed.

Many systems, for example Dynamics GP, have as many as 3 lines of addresses, in addition to name, contact name, city, state and zip.  I rarely see anyone use line 3 but for the rest here is the method I developed to print all this in SQL Reports.

My method uses text concatenation of the separate address fields into a single field using SSRS expressions.  Whether you use a text box or a table the result is the same.

=TRIM(address1)+
TRIM(address2)+
IIF(TRIM(address2)="","",vbcrlf)+
TRIM(address3)+
IIF(TRIM(address3)="","",vbcrlf)+
TRIM(city)+", "+TRIM(state)+"  "+TRIM(zip)

No comments:

Post a Comment