I am trying to import an excel spreadsheet using the below VBA code. Before bringing it in I am also deleting the current contents of the table.
DoCmd.RunSQL ("DELETE * FROM REBATE_PROG")
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "REBATE_PROG", filepath, True
The rebate_prog table already has fields defined as long text (which is the old memo field, as per my understanding) which should be able to store > 255 chars.
Is there a reason why Access would be truncating the contents?
Some of the things that I have tried, without success:
Is there a way I can import the excel spreadsheet without access truncating the fields?
Found a way of fixing this issue. There might be other solutions out there as well but this one seemed to have worked for me the best. Below is a step by step of what I did:
Note: The structure I created for this table is exactly as it is in the file I intend on importing.
LEN()
function as LEN(<Cell in the long text field>)
. And then used this field to sort all records in descending order and saved the file. I had to do this because Access while importing looks at a few top rows to determine how much data needs to be imported from the column (I learned this after going through a few forums).Note: You could also create a VBA code which does the sorting in descending order for you right before importing, but I haven't executed that yet. If you do, please do share the code here!
DoCmd.RunSQL ("DELETE * FROM REBATE_PROG")
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "REBATE_PROG", filepath, True