【发布时间】:2018-01-15 10:07:45
【问题描述】:
我正在将访问文档从 Excel 导入 Access,我需要将第一列作为主键,但不确定用于执行此操作的方法。
我的代码:
Public Sub ImportProtected(strFile As String, _
strPassword As String)
Dim oExcel As Object, oWb As Object
Set oExcel = CreateObject("Excel.Application")
Set oWb = oExcel.Workbooks.Open(FileName:=strFile, _
Password:=strPassword)
DoCmd.TransferSpreadsheet acImport, _
acSpreadsheetTypeExcel9, "_tmp_table", strFile, -1
oWb.Close SaveChanges:=False
oExcel.Quit
Set oExcel = Nothing
End Sub
我使用以下代码调用代码:
ImportProtected "C:\Daves Work\Projects\ID.xlsm", "1234"
这一切都很好,但我需要第一列成为主键,并在显示数据的行中有数字 1、2、3、4 等。
帮助
【问题讨论】:
标签: ms-access vba ms-access-2010