Link to home
Start Free TrialLog in
Avatar of marcthib
marcthibFlag for United States of America

asked on

Make Access stop removing CR LF TAB hidden chars when importing Excel worksheet

Hoping someone has done this and has a nifty piece of VBA or knows how to use the Access External Data functionality that solves my issue. I have a very large Excel worksheet with several columns of data containing hidden chars TAB CR LF that must be preserved when importing to Access so the data does not display in a single line of text when end-users see it. The data will be displayed in a subform Datasheet View. I am using Access 2016. Right now Access is removing the above hidden characters during the import, it does however keep the Space hidden character intact. The Excel column data is large enough it must be loaded as Long Text. Not all columns in my spreadsheet contain the above data, just a few specific ones. Has anyone seen this and solved it? tia, Marc
Avatar of ste5an
ste5an
Flag of Germany image

hmm, sure? Can you provide a sample Excel?
Also keep in mind, that the characters maybe there, but not displayed like the manual line break in Excel. This is a LF, which is not shown but in the data.

E.g.

SELECT [yourColumn], Replace([yourColumn];Chr(10);"¶") FROM yourTable;

Open in new window

Avatar of marcthib

ASKER

Sure! see attached Excel file.  Here is more info, let me know if the screen shots do not make it over.

Excel data prior to importing to Access, F2 on the cell shows the formatting within the cell
User generated image
Same data in Notepad++  in Hex view
User generated image
After importing to Access, now shows as one line of text
User generated image
Same Access contents viewed in Notepad++ Hex view, 0d(CR) 0a(LF) 09(TAB) are now gone
User generated imageSampleExcelToLoadToAccess.xlsx
hmm.. the problem is that the line break in Excel is a LF, not CRLF. Also how should be a tabulator interpreted without tab stop?:

Replace(Replace([CommodityNameVerbose_LT];Chr(10);Chr(13) & Chr(10));Chr(9);Space(4))

Open in new window


User generated imageEE29094702.accdb
Thanks lots!   I'll give it a try!  Marc
Hi ste5an,

I experimented with various amounts of Tabs in the data, the Replace handles them nicely.  One thing I am noticing is that if I double click the Query itself the output is perfect!  But if I open the form, the bottom two fields only display part of the data.  I checked all the properties on the fields but I cannot see why that is happening.  Any thoughts or suggestions?

Query output
User generated image
Form does not display all data bottom two fields
User generated image
thanks again! Marc
Just set the Scrollbars property of the TextBox to Vertical only.
Thanks ste5an!  I also saw in another post removing the "@" from the Format property lets all characters show up.  That and the vertical scroll bar were the final touches.  You have been great, your solution is wonderful!  Marc
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.