Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

How to display Line Breaks and Tabs in SSRS

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

  • Suggested answer
    Robyn333 Profile Picture
    Robyn333 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
    jgv 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
    Robyn333 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
    Community Member Microsoft Employee 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
    Robyn333 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
    Richard Whaley 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
    Victoria Yudin 22,766 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans