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
marcthibAsked:
Who is Participating?
 
ste5anSenior DeveloperCommented:
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

0
 
marcthibAuthor Commented:
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
Excel data, F2 on the cell
Same data in Notepad++  in Hex view
Same Excel data, Notepad++ Hex view
After importing to Access, now shows as one line of text
Access one line of text
Same Access contents viewed in Notepad++ Hex view, 0d(CR) 0a(LF) 09(TAB) are now gone
Same Access data Notepad   Hex viewSampleExcelToLoadToAccess.xlsx
0
 
ste5anSenior DeveloperCommented:
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


Capture.PNGEE29094702.accdb
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
marcthibAuthor Commented:
Thanks lots!   I'll give it a try!  Marc
0
 
marcthibAuthor Commented:
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
Query Output looks great
Form does not display all data bottom two fields
Form partial data
thanks again! Marc
0
 
ste5anSenior DeveloperCommented:
Just set the Scrollbars property of the TextBox to Vertical only.
0
 
marcthibAuthor Commented:
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
0
All Courses

From novice to tech pro — start learning today.