web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

How to display Line Breaks and Tabs in SSRS

(0) ShareShare
ReportReport
Posted on by 170

I am trying to bring the SY03900.txtfield onto a SSRS report.  I would like to preserve both the line breaks and the tabs that have been entered in GP. 

I am using the following to preserve line breaks 

 

=REPLACE(Fields!txtfield.Value,chr(13),vbCrLf)  

(this formula is from a newsletter from Victoria Yudin's Flexible Solutions.)

 

How can I change this formula to also preserve the tabs (ie when the user inputting the data hits the tab key)?

Thank you.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Robyn333 Profile Picture
    170 on at
    Re: How to display Line Breaks and Tabs in SSRS

    jgv, thanks for posting this.  I have been searching for a solution to this for some time.

    The following is working for us:

    =Replace(Replace(Fields!txtfield.Value,chr(13),vbCrLf),Convert.ToChar(9), New String(Convert.ToChar(160), 4))  

    Many thanks to everyone for responding.

  • jgv Profile Picture
    20 on at
    Re: How to display Line Breaks and Tabs in SSRS

    In HTML you have to use a non-breaking space which is character code 160. To replace a tab with 4 non-breaking spaces you would use something like this:

    =Replace(Fields!txtfield.Value, Convert.ToChar(9), New String(Convert.ToChar(160), 4))

    Keep in mind that this may look and act like a space but it's not. As an example, if you insert a non-breaking space between "Bob" and "Smith" you would not be able to find this if you exported to excel and searched for "Bob Smith".

  • Robyn333 Profile Picture
    170 on at
    Re: How to display Line Breaks and Tabs in SSRS

    Hi Scott,

    Thanks for your reply.  

    Can you please tell me again what is the code to add spaces that will not be trimmed in HTML?  To me it looks like you have typed some spaces between quotes, but I already tried this and it gets trimmed.  Are they different types of quotes?

    Thanks!

  • Community Member Profile Picture
    on at
    Re: How to display Line Breaks and Tabs in SSRS

    Yes you are correct HTML will reduce multiple spaces to a single space. The code to add a space that will not be trimmed off is:  . So in your case to get the spaces you need:

    =replace(replace(Fields!txtfield.Value,chr(13),vbCrLf),chr(9),”    “)

    This however will probably print on the Excel and PDF exports.

    Scott

  • Robyn333 Profile Picture
    170 on at
    Re: How to display Line Breaks and Tabs in SSRS

    Thanks for the replies.

     

    I have tried the following:

    1)  =replace(replace(Fields!txtfield.Value,chr(13),vbCrLf),chr(9),vbTab)

     

    vbTab does not seem to work at all.

     

     

    2)  =replace(replace(Fields!txtfield.Value,chr(13),vbCrLf),chr(9),SPACE(4))

    3)  =replace(replace(Fields!txtfield.Value,chr(13),vbCrLf),chr(9),”    “)

     

    2 and 3 work sufficiently in Visual Studio and when exported to Excel and PDF, but in Report Manager the four spaces are reduced to a single space.

     

    I'm not sure, but I’m guessing that HTML treats whitespace differently.

  • Richard Whaley Profile Picture
    25,195 on at
    Re: How to display Line Breaks and Tabs in SSRS

    Even after reading Victoria's comment, try

    =Replace(fieldstxtfield.Value,chr(8),"        ")

  • Victoria Yudin Profile Picture
    22,768 on at
    Re: How to display Line Breaks and Tabs in SSRS

    Robyn,

    Thanks for subscribing to our newsletter!  We have experimented with various options for tabs, however, have not found anything that works correctly or consistently.  :-(

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans