×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

DoCmd.TransferSpreadsheet Still Won't Work. Run-time Error 2391

DoCmd.TransferSpreadsheet Still Won't Work. Run-time Error 2391

DoCmd.TransferSpreadsheet Still Won't Work. Run-time Error 2391

(OP)
There have been a lot of posts on Run-time error 2391 but I have never seen an answer to it:

CODE

Private Sub CMD_IMPORT_NEW_DATA_Click()

    Dim varDate As String
    Dim varSpecification As String
    Dim varTable As String
    Dim strInputFileName As String

    varTable = "TBL_AR_AGING"
    varDate = Format(Format(Now(), "DDMMMYYYY_HhMmSs_AMPM"), ">")
    
    strInputFileName = ahtCommonFileOpenSave( _
                    OpenFile:=False, _
                    DialogTitle:="Please select the excel file you want to import...", _
                    Flags:=ahtOFN_HIDEREADONLY)

    If (strInputFileName & "") = "" Then
    Else
    
    'strInputFileName = Chr(34) & strInputFileName & Chr(34)
        
    DoCmd.OpenQuery "QDEL_AR_AGING"
    
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, varTable, strInputFileName
    
    End If

This produces an error: Field 'F1' doesn't exist in destination table "TBL_AR_AGING"

The field names are the same in the excel spreadsheet as the table (in fact the table was made from an import of the same file), there are no spaces in the directory of strInputFileName, I've tried every Excel type (4 through 9), and when I import the excel file by going through the wizard it works every time - just not via VBA code.

Any help would be appreciated.

RE: DoCmd.TransferSpreadsheet Still Won't Work. Run-time Error 2391

Does your XLS contain fieldnames for the first row?

if So try adding comma 1 on the end...

CODE

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, varTable, strInputFileName, 1

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts

RE: DoCmd.TransferSpreadsheet Still Won't Work. Run-time Error 2391

(OP)
Dude I've have been trying to figure that out for a week now, right under my nose - awesome - ty much.

RE: DoCmd.TransferSpreadsheet Still Won't Work. Run-time Error 2391

no worries, that's that we're here for winky smile

Funny how somethings are so easy when you know how, and seem imposible when you don't lol

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts

RE: DoCmd.TransferSpreadsheet Still Won't Work. Run-time Error 2391

yes, 1  = true , though not always, switching between so many languages, I get confused very easily!

It works so I don't question it, but I'd go with PHV, he's normally right about these things winky smile

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts

RE: DoCmd.TransferSpreadsheet Still Won't Work. Run-time Error 2391

(OP)
Thanks PHV - now I just have to come up with some lame excuse to my boss as to why I'm an idiot for not reading the specs.

RE: DoCmd.TransferSpreadsheet Still Won't Work. Run-time Error 2391

corrupt data file usually works winky smile

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close