+ Reply to Thread
Results 1 to 20 of 20

Excel to Access - Text LF and CR

  1. #1
    Registered User
    Join Date
    05-21-2012
    Location
    tampa
    MS-Off Ver
    Excel 2003
    Posts
    10

    Excel to Access - Text LF and CR

    So I am trying to import a sheet from Excel into Access and one of my data columns has large amounts of text in each cell.

    This data has carriage returns and such like:

    This is sample text.
    I have lines of text.

    I also have full paragraphs.



    Now this text ends up in Access like this:

    This is sample text.I have lines of text.I also have full paragraphs.

    How can I maintain my lf and cr when importing into access?

  2. #2
    Registered User
    Join Date
    05-21-2012
    Location
    tampa
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Excel to Access - Text LF and CR

    Nothing on this? It seems like this would be a simple thing...

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Excel to Access - Text LF and CR

    Hi TriAdX,

    Access has a memo field that will allow CrLf characters in it. In VB talk they are called "vbNewLine".

    My best answer is to give it a try and see what happens.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    05-21-2012
    Location
    tampa
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Excel to Access - Text LF and CR

    I have tried using the Memo data type and it still just treats the CR and LF as if they werent there.

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Excel to Access - Text LF and CR

    Post a sample spreadsheet and let me try.
    I wonder if 2003 Excel and Access were as versatile as 2010?
    Click on Go Advanced below the message area and then on the paper clip icon above the advanced message area to attach a sample.

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,893

    Re: Excel to Access - Text LF and CR

    You have limited flexibility when importing from Excel to Access. Access tries to determine the field type on its own and doesn't give you the opportunity to change. I have found that when there are particular fields that I want to import with particular characteristics, it is best to convert the Excel file to a .CSV file and then import it. While the import wizard is open, click on the Advanced button and you can select the type of field each Excel column should be. This is true on earlier as well as later versions of Access.

    Alan
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  7. #7
    Registered User
    Join Date
    05-21-2012
    Location
    tampa
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Excel to Access - Text LF and CR

    AccessImport.xlsx

    above is a simple sample sheet. I just want to maintain the carriage returns and line feeds in "Data 4"

  8. #8
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Excel to Access - Text LF and CR

    Hi,

    I took your XL and imported it into 2010 Access and let the long filed be a type of "memo". It looked good when I got done. This site won't allow me to attach a .accdb or I'd give it back to you.

  9. #9
    Registered User
    Join Date
    05-21-2012
    Location
    tampa
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Excel to Access - Text LF and CR

    hmm.. Maybe it's new for 2010 that it imports no issues. I might need to upgrade.

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,893

    Re: Excel to Access - Text LF and CR

    I tested the data import in 2002 (converting the Excel file to an .xls first) and it did parse the data in Memo format. It did show ASCII characters, however where the LF and CR were located.

    Marvin, if you zip the file, I think you can upload it to the site.

  11. #11
    Registered User
    Join Date
    05-21-2012
    Location
    tampa
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Excel to Access - Text LF and CR

    So I just imported my sample into access 2007 and chose memo as the field type and it still crammed all CR and LF together when I view the table in access...

    what am I doing wrong. it seems very straight forward yet, I get no formatting in access... I get no ASCII characters.. just all the lines ran into one.

  12. #12
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,893

    Re: Excel to Access - Text LF and CR

    I just imported into AC 2007 and got the same as you described. I then imported it into AC2010 and saw no discernible difference between what I got in AC2007. I think that this is a quirk within Access. I don't think that there is a viable solution. Everything was crammed together.
    Alan

  13. #13
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Excel to Access - Text LF and CR

    Hey Alan,

    Great idea. See if you can unzip this and read it.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    05-21-2012
    Location
    tampa
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Excel to Access - Text LF and CR

    AccessExample2.jpg
    So I opened your DB and as you can see from my attached screenshot your DB still shows all of the text crammed together.

    it didnt even show the ASCII characters for LF or CR...

    Is this an issue or setting in my access?

    Any other ideas? This is very important to my project as it MUST be in Access and it is currently in excel and I NEED to keep all cr and lf... there is no way I can go through the access fields and re-add all the cr and lf....
    Last edited by TriAdX; 05-23-2012 at 11:21 AM.

  15. #15
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,893

    Re: Excel to Access - Text LF and CR

    Doing a little bit of research and found this. May be a bit of a hassle but it will probably work. Use the Find and Replace Icons in both Excel and Access.

    http://msgroups.net/microsoft.public...d-cr-lf/123927

  16. #16
    Registered User
    Join Date
    05-21-2012
    Location
    tampa
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Excel to Access - Text LF and CR

    How do I find and replace an "Alt-Enter" in Excel?

  17. #17
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,893

    Re: Excel to Access - Text LF and CR

    Just found a solution. Google ASAP Utilities for a free download. I've been struggling on this for the last hour and that may be the solution. Replace the LF and CR with another character that you can reverse in Access. Perhaps something that you would not use in the comments, ie. # or ^.

    Let us know if this is successful for you. I am curious.

    Alan

  18. #18
    Registered User
    Join Date
    05-21-2012
    Location
    tampa
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Excel to Access - Text LF and CR

    How do I find and replace an "Alt-Enter" or the LF/CR in Excel?

  19. #19
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,893

    Re: Excel to Access - Text LF and CR

    You don't. That is why you need to get the ASAP utility. I researched this and Excel doesn't have the same find feature that word has for special characters.

    Here is a link to the download which is at the top of the page.

    http://www.asap-utilities.com/blog/i...urns-in-cells/

  20. #20
    Registered User
    Join Date
    05-21-2012
    Location
    tampa
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Excel to Access - Text LF and CR

    So.. here is what I have gotten!

    First... in excel I just did a find and replace
    Find: Ctrl-J
    Replace: "|"

    Then I imported my sheet into access.

    Then ran a SQL query:

    UPDATE MyTable SET MyTableColumn = Replace([CardRulesText],"|",Chr(13));

    And all of my data now has the line returns that it had in Excel! Thanks for all your help guys!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1