如何在Access中使用VB将所有记录插入表中

时间:2019-06-30 02:11:51

标签: vba ms-access

我正在尝试附加一个Excel文件,该文件的路径来自当前表单上名为txtFileName的控件;我正在尝试将其附加到表Load Report 1中。

SQL语句导致语法错误:

  

不完整的条款

我的代码如下:

Private Sub Import_Click()

    Dim FSO As New FileSystemObject, fileName As String, tableName As String, item As Variant, diag As Office.FileDialog

    Set diag = Application.FileDialog(msoFileDialogFilePicker)

    For Each item In diag.SelectedItems
        Me.txtFileName = item
    Next

    If FSO.FileExists(Me.txtFileName) Then
        DoCmd.RunSQL ("INSERT INTO [Load Report1].*,Select Me.txtFileName.*,From Me.txtFileName.*")
    Else
        MsgBox "File Not Found!"
    End If

End Sub

0 个答案:

没有答案