Replace new line character with space

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mc223
    New Member
    • Mar 2010
    • 3

    Replace new line character with space

    I have data in ms access which has new line characters.I want to use the REPLACE function to replace all new lines in that particular column so that the data appears in a single line.What update query should I use?
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Assuming your Table Name is tblTest, and your Field is named [Field1]:
    Code:
    UPDATE tblTest SET tblTest.Field1 = Replace([Field1],Chr$(13) & Chr$(10)," ");

    Comment

    • mc223
      New Member
      • Mar 2010
      • 3

      #3
      I actually tried the above query twice:once with chr(10) and next update query with chr(13) and it worked fine then

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32634

        #4
        If the data were actually New Lines (vbCrLf or vbNewLine) then ADezii's code would work faultlessly. It's common for such data to contain other sequences though, especially if they are embedded within fields. In such an instance it is likely you'll need to replace either or both of Chr(13) and Chr(10). Glad you got it sorted anyway :)

        Welcome to Bytes!

        Comment

        Working...