59

I'm having trouble adding a line break in SSRS 2008.

I've tried all of these different ways but nothing is doing it.

"+ chr(10) +" , "& chr(10) &" , "& chr(13) & chr(10) &" , "& vbcrlf &" , "+ vbcrlf +" , "Environment.NewLine"

Here's my textbox expression:

=IIF(First(Fields!VCHTYPE.Value, "Dataset1")="C","This is a huge paragrpah of text." +
vbcrlf + "separated by line feeds at each paragraph." +
vbcrlf + vbcrlf + "I want to separate the paragraphs." +
vbcrlf + vbcrlf + "Its not working though."
, "This is the second huge paragraph of text." +
vbcrlf + "separated by line feeds at each paragraph." +
vbcrlf + vbcrlf + "I want to separate the paragraphs." +
vbcrlf + vbcrlf + "Its not working though." )
Jt2ouan
  • 1,964
  • 9
  • 33
  • 55
  • It works for me. Check your Error List when you preview it. Also just to rule it out, try replacing the VCHTYPE value with "C". – StevenWhite Feb 28 '14 at 19:48

10 Answers10

95

UseEnvironment.NewLine instead of vbcrlf

John Verco
  • 1,357
  • 9
  • 6
  • Can you elaborate on why to use `Environment.NewLine` instead of `vbcrlf`? What are the benefits of the one over the other, or why not use `vbcrlf`? – John G Hohengarten May 06 '20 at 21:58
  • As a note on this (as covered by Samrat Sarang and krilovich answer below), if your placeholder is set to HTML then you will need to use '
    ' as newline / vbcrlf will not work.
    – Mathew Paxinos Aug 12 '22 at 00:38
  • If RDL Sandboxing is enabled you cannot use `Environment.NewLine`, you won't be able to publish the report. `VbCrLf` is the way to go in that scenario. – Alex Nov 08 '22 at 11:53
23

If your placeholder is in html enabled mode then "<br />" will work as a newline

krilovich
  • 3,475
  • 1
  • 23
  • 33
  • As a note on this (as covered by Samrat Sarang answer below), this is the only way to do newline if your placeholder is set to HTML. – Mathew Paxinos Aug 12 '22 at 00:37
14

This works for me:

(In Visual Studio)

  1. Open the .rdl file in Designer (right-click on file in Solution Explorer > View Designer)
  2. Right-click on the Textbox you are working with, choose Expression
  3. In the Set expression for: Value box enter your expression like:

    ="first line of text. Param1 value: " & Parameters!Param1.Value & Environment.NewLine() 
    & "second line of text. Field value: " & Fields!Field1.Value & Environment.NewLine() 
    & "third line of text."
    
Brian D
  • 2,570
  • 1
  • 24
  • 43
9

In Order to implement Line Break in SSRS, there are 2 ways

  1. Setting HTML Markup Type
    Update the Markup Type of the placeholder to HTML and then make use of <br/> tag to introduce line break within the expression

="first line of text. Param1 value: " & Parameters!Param1.Value & "<br/>" & Parameters!Param1.Value

  1. Using Newline function
    Make use of Environment.NewLine() function to add line break within the expression.

="first line of text. Param1 value: " & Parameters!Param1.Value & Environment.NewLine() & Parameters!Param1.Value

Note:- Always remember to leave a space after every "&" (ampersand) in order to evaluate the expression properly

Samrat Sarang
  • 131
  • 1
  • 4
8

You should NOT quote your Environment.NewLine man. Try "Your Text" & Environment.NewLine.

Vin.X
  • 4,759
  • 3
  • 28
  • 35
8

Use the vbcrlf for new line in SSSR. e.g.

= First(Fields!SAPName.Value, "DataSet1") & vbcrlf & First(Fields!SAPStreet.Value, "DataSet1") & vbcrlf & First(Fields!SAPCityPostal.Value, "DataSet1") & vbcrlf & First(Fields!SAPCountry.Value, "DataSet1") 
Sumant Singh
  • 904
  • 1
  • 14
  • 16
4

I've always had luck with the Chr(10) & Chr(13) - I have provided a sample below. This is an expression for an address text box I have in a report.

=Iif(Fields!GUAR_STREET_2.Value <> "",Fields!GUAR_STREET.Value & Chr(10) & Chr(13) & LTrim(Fields!GUAR_STREET_2.Value),Fields!GUAR_STREET.Value)

Also, if you are building a string you need to concatenate stuff together with an & not a + Here is what I think your example should look like

    =IIF(First(Fields!VCHTYPE.Value, "Dataset1")="C","This is a huge paragrpah of text." &
Chr(10) & Chr(13) & "separated by line feeds at each paragraph." &
Chr(10) & Chr(13) & Chr(10) & Chr(13) & "I want to separate the paragraphs." &
Chr(10) & Chr(13) &  Chr(10) & Chr(13) & "Its not working though."
, "This is the second huge paragraph of text." &
Chr(10) & Chr(13) & "separated by line feeds at each paragraph." &
Chr(10) & Chr(13) & Chr(10) & Chr(13) & "I want to separate the paragraphs." &
Chr(10) & Chr(13) & Chr(10) & Chr(13) & "Its not working though." )
Jordan H
  • 741
  • 1
  • 7
  • 16
2

It wasn't working for me either. vbcrlf and Environment.Newline() both had no effect. My problem was that the Placeholder Properties had a Markup type of HTML. When I changed it to None, it worked like a champ!

1

You Can Use This One

="Line 1" & "<br>" & "Line 2"
1

In my case, Environment.NewLine was working fine while previewing the report in Visual Studio. But when I tried to publish the rdl to Dynamics 365 CE, I received the error "The report server has RDLSandboxing enabled and the Value expression for the text box 'Textbox10' contains a reference to a type, namespace, or member 'Environment' that is not allowed."

So I had to replace Environment.NewLine with vbcrlf.

bpfingst
  • 36
  • 2