Avatar of SteveL13
SteveL13
Flag for United States of America asked on

Importing text string > 255 characters

I am importing a record or records from an Excel file.  One of the fields in the file contains more than 255 characters.  When I import the file the field is truncated at stops at 255 characters.  Here is my VBA code:

    'Import Excel file into tblTempImport
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tblTempImport", Me.FileList, True
 
    'Code to delete any import error tables
    Dim tblDef As TableDef
    For Each tblDef In CurrentDb.TableDefs
    If InStr(1, tblDef.Name, "ImportError") > 0 Then
        DoCmd.SelectObject acTable, tblDef.Name, True
        'DoCmd.PrintOut
        DoCmd.DeleteObject acTable, tblDef.Name
        Beep
        'MsgBox "There was an error importing all of your records." & vbCrLf & vbLf & "An error report was sent to your default printer." & vbCrLf & vbLf & "The error report will detail the error reason for each field and row number for each record that was not successfully imported from your file." & vbCrLf & vbLf & "Please correct all errors and import your data again.", vbInformation, "Import Errors"
    End If
    Next tblDef

    'Use tblTempImport to add records to table named tblImportRecords
    Dim db As Database
    Set db = CurrentDb

    db.Execute "apndtblqryImportRecords", dbFailOnError

    'Run query to delete records from tblTempImport
    db.Execute "delqryDeleteRecordsFromtblTempAppealsImport", dbFailOnError

    MsgBox "The import has been executed."
    DoCmd.Close , ""

Open in new window

Microsoft Access

Avatar of undefined
Last Comment
Dale Fye

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Bill Bach

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SteveL13

ASKER
It was set to Short Text.  I changed it to Long Text and it worked fine.
Dale Fye

steve, don't forget to close this out.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy