Import .DBF file in MS Access after button press, Using VBA

 ̄綄美尐妖づ 提交于 2021-02-16 18:37:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!