TransferText将CSV文件复制到临时表中

时间:2019-05-24 09:43:44

标签: sql vba ms-access

我必须将一个csv文件复制到Access中,该文件保持动态变化,因此已将文件存储到临时文件中,然后从中读取。在Access 2010中它可以正常工作,但是Access 2013会引发错误“找不到临时表”。

这已经在起作用:

DoCmd.TransferText acImportDelim, , "DLPTemp3", filename, True.

DLPtemp3是临时表。

 Dim ImportIdx As Integer, Rs1 As ADODB.Recordset, str1 As String, Str2 As String, str3 As String, a As Currency
   ImportIdx = InStr(1, Me.txtEbayPath, "csv")             
        If ImportIdx = 0 Then
             DoCmd.TransferText acImportDelim, , "DLPTemp3", filename, True
        Else
            MsgBox "Invalid file format."
        End If

   Set Rs1 = mdbx.OpenRecordset("SELECT * FROM DLPTemp3;", SeeChangesReadWrite)

  If Rs1.Fields.Item(17).Name = "Postage and packaging" Then
    DoCmd.Close acTable, "DLPTemp3"
    mdbx.Execute ("DROP TABLE DLPTemp3")
  End If

它抛出“无效对象DLPTemp3”。我试图将其声明为全局变量,但这似乎也不起作用。

0 个答案:

没有答案