问题
I have to import .DBF file int MS Access Table On button click.
The file name is SourceTable.dbf ; Access database is StudentDataBase.accdb and the table I want to insert it is named myTable.
First I want to ask: do I need to have the same fields in the table or it can just be a blank table. I have the following sample code:
DoCmd.TransferDatabase transfertype = acImport, databasetype = "dBase III", DatabaseName = "C:/SourceTable.dbf", objecttype = acTable, Source = "SourceTable", destination = "myTable"
Where in the code do I specify the database, where the table is (StudentDataBase)?
And when I run it like that, i get "Run-time error 2507 The 0 type isn't installed database type or doesn't support the operation you chose."
I'm new To Access and VB programming, so please add some guides on how to rewrite that code line.
Thanks!
回答1:
A quick test suggests that "SourceTable.dbf" is problematic because it does not conform to the old 8.3 file naming convention. I just got Access 2010 to import "C:\Source.dbf" into an Access table named [FromDBF] via VBA using
DoCmd.TransferDatabase _
TransferType:=acImport, _
DatabaseType:="dBASE III", _
DatabaseName:="C:\", _
ObjectType:=acTable, _
Source:="Source", _
Destination:="FromDBF"
来源:https://stackoverflow.com/questions/22672730/import-dbf-file-in-ms-access-after-button-press-using-vba