Results 1 to 6 of 6
  1. #1
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146

    vba to remove carriage return and line feed in long text field


    My searches indicate I should be able to use this:
    Code:
    EventNotes = Replace(EventNotes, Chr(13) & Chr(10), "")
    This isn't working for me.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    try:
    Replace(EventNotes, vbcrlf, " ")

  3. #3
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146
    Same thing, nothing happens.

    If I use this on long text field:
    Code:
    EventNotes = Replace(EventNotes, "+", "")
    EventNotes = Replace(EventNotes, vbcrlf, "")
    on a field that contains:
    + testing

    123

    I get:
    testing

    123

    but I can't seem to remove the line between texts

  4. #4
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Try adding the start optional parameter

    Replace(EventNotes , Chr(13) & Chr(10),' ',1)

    I had a weird fault with it not working without that.
    Also try it on a short text version in case it's an issue with the long text field.
    Is this RTF - the char codes might be completely different?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146
    Yes it is RTF

    It seemed to work with Short Text version, only it deleted all carriage returns

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    RTF is a whole 'nother ball game. The problematic "characters" or codes are likely <div> or <P> or <B> but likely just <div>.

    Such formatting is ignored by the apps that render the plain text, but they are still there. If you test for Left(strMyString,3) where my string contains "dog" with plain text you will get 'dog'. With rtf you will get <di

    You will have to output some of your records/fields into code or the immediate window of the vb editor to see what you're dealing with. If you don't need font formatting in the field, save yourself a lot of headaches and format it as plain text. Otherwise you're stuck with having to find and delete not only leading tags, but closing ones as well.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How can I import long text with line breaks from .XML
    By PeterG in forum Import/Export Data
    Replies: 3
    Last Post: 07-11-2020, 03:54 PM
  2. Line feed for use in MS Outlook email
    By aytee111 in forum Programming
    Replies: 10
    Last Post: 10-21-2016, 12:50 PM
  3. Replies: 2
    Last Post: 07-09-2014, 06:41 PM
  4. Importing data with line feed
    By wlcummings in forum Import/Export Data
    Replies: 10
    Last Post: 05-18-2011, 12:52 PM
  5. Replies: 1
    Last Post: 11-05-2010, 04:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums