【问题标题】:Transfer Spreadsheet to Access Database with VBA使用 VBA 将电子表格传输到 Access 数据库
【发布时间】:2018-07-11 09:00:38
【问题描述】:

我有一个浏览按钮,可以在 textbox5 中选择并放置文件名和路径。我需要在我的文件名中使用相同的值,但它不起作用。它抛出:

运行时错误 2522 - 操作或方法需要文件名参数

Private Sub Command10_Click()
  Dim dbs As DAO.Database
  Dim td As DAO.TableDef
  Dim fileName As String

'set current database
 Set dbs = CurrentDb

 Me.Text5 = fileName

DoCmd.TransferSpreadsheet acImport, , "tblS3DimportTemp", fileName, True
 MsgBox "Data Uploaded!"

End Sub

【问题讨论】:

    标签: vba excel import-from-excel


    【解决方案1】:

    代替:Me.Text5 = fileName

    写: fileName = Me.Text5

    在许多编程语言中,左侧变量获取右侧变量的值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-22
      • 2010-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多