使用VBA代码重新设置索引和字段选择后再进行导入。
示例代码:
DoCmd.TransferText acImportDelim, "Import Specification Name", "Table Name", "File Path", hasfieldnames
'重新设置索引
CurrentDb().TableDefs("Table Name").Indexes.Delete "Index Name"
CurrentDb().TableDefs("Table Name").Indexes.Refresh
Set idx = CurrentDb().TableDefs("Table Name").CreateIndex("Index Name")
With idx
.Fields.Append .CreateField("Column Name 1")
.Fields.Append .CreateField("Column Name 2")
End With
CurrentDb().TableDefs("Table Name").Indexes.Append idx
CurrentDb().TableDefs("Table Name").Indexes.Refresh
'重新设置字段选择
CurrentDb().Execute "DELETE FROM [Table Name] WHERE [Column Name] IS NULL;"