DoCmd.TransferSpreadsheet acImport - Long Text Import Problem

Ivan Howard

Active Member
Joined
Nov 10, 2004
Messages
333
Hello all,

Please could someone kindly give me a hand. I have been looking for a solution for 2 days and keep turning up empty handed.

I am using the following VBA code to import data from a predefined spreadsheet containing 84 columns into an existing Access Table. The macro imports 83 of the columns 100% accurately and I don't get any run-time errors. The issue that I have is that the remaining column is a "Comments" field that contains some records with more than 255 characters. These records gets truncated every time I run the process.

The "Comments" column in the spreadsheet has been run through Text To Columns as "Text" and the cell formatting has also been set to "Text".
The "Comments" field in the Access Table is set to "Long Text" and it does not contain any formatting parameters (@) at all.

I have removed the "Comments" field, saved the Table, Compact and Repaired the database and recreated the field and it still won't import the dataset without truncating the "Comments" field.

VBA Code:
DoCmd.TransferSpreadsheet acImport, 10, strTableToRefresh, strSourceFileFullPath, True, strSourceFileImportRange

Any ideas as to what I might be doing wrong?

Thanks very much in advance.
Ivan
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
You are welcome.
Yeah, trying to import long text fields is a pain!
 
Upvote 0
You are welcome.
Yeah, trying to import long text fields is a pain!

I had a look at the link you sent through - thank you.

I tried the "Rich Text" setting and it didn't work.

However, on the same thread you sent, I then saw something that said something about the first couple of records imported, determine some field settings in the Access Table - which I find completely ridiculous... but I indulged... Thankfully the pre-defined dataset that I import into Access, is created through an Excel macro that I created and this macro essentially cleans, re-formats, etc. the data before it is imported into Access. I edited the Excel macro to do the following:

1. Insert a column after the "Comments" column.
2. In the new column, I calculated the length of the comment in the adjacent cell and filled the range.
3. Copy and pasted the calculated lengths as values.
4. Sorted the lengths in descending order.
5. Deleted the inserted column.
6. Saved and Closed.

I then imported the file and it works 100%.

Why oh why!

Thank you for pointing me in the right direction Joe. I can now put the last 2 days to bed!
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top