We help IT Professionals succeed at work.

Error 31519 'You cannot Import This File' when attempting Import

mlcktmguy
mlcktmguy asked
on
I just received a test file from a client.  It is in fixed fixed length format.

I want to import this file into my Access 2013 application but I am getting a '31519', 'You cannot Import This File'  error when I execute:

DoCmd.TransferText , acImportFixed, _
                     "WRBImport_AddRecord", _
                     "WRBtoGRB_AcctAdd", _
                     False

Open in new window


I have attached my import spec, the table definition and the test file.

Any ideas?
ImportSpec_AddRecord.xlsx
atblOfImportExortSpecs.rtf
MJO_PHLSHGRB_20181015_01.txt
Comment
Watch Question

President / Owner CARDA Consultants Inc.
Distinguished Expert 2018
Commented:
Try something more along the lines of
DoCmd.TransferText transferType:=acImportFixed, SpecificationName:="WRBImport_AddRecord", TableName:="WRBtoGRB_AcctAdd", FileName:="C:\...\MJO_PHLSHGRB_20181015_01.txt", hasfieldnames:=False

Open in new window

Dale FyeOwner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010

Commented:
Have you tried doing a manual upload of the file with that import specification?  It might be that the file is not configure the way you would expect, and you are missing the file name from the TransferText method.
Distinguished Expert 2017

Commented:
Does the text file contain CRLF to separate records?  It looks like you either have a single record in the test file or the file was created on Unix and doesn't have the proper DOS record marks.

I don't know what the .rtf file is supposed to be.
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
You must use the correct syntax.
I created a minimal import specification, imported manually with success, then ran an import from code:

DoCmd.TransferText  _
    acImportFixed, _
    "MJO_PHLSHGRB_20181015_01 Test", _
    "WRBtoGRB_AcctAdd", _
    "C:\Test\MJO_PHLSHGRB_20181015_01.txt", _
    False

Open in new window

and it created the table with no import errors.

See the attached, please.
Database1.accdb

Author

Commented:
Thanks You.  After all these years still making syntax errors.