Programmatically import CSV data to Access

2019-04-15 02:16发布

I have an Access database and the source of data comes from generated CSV files. I'd like to have an easy way for the users to simply select the data file and import it. Import should append the existing data to the data already in the data table. Is there a way in Access to create a file selector and import using saved CSV import settings that are already in the file?

2条回答
做个烂人
2楼-- · 2019-04-15 02:45

You can use the built in file dialog to do this (access 2003 and later)

Dim f    As Object
Set f = FileDialog(3)
f.InitialFileName = "c:\InCommingData\"
f.Filters.Add "text", "*.csv"

If f.Show Then
   DoCmd.TransferText acImportDelim, "mySpec", "Your Table", f.SelectedItems(1)
End If
查看更多
登录 后发表回答