TransferDatabase Creates Duplicate Tables (1 Viewer)

duluter

Registered User.
Local time
Yesterday, 22:01
Joined
Jun 13, 2008
Messages
101
I want to import data from three DBF files into three existing tables in my database. Following a suggestion from another forum user, I am using the following code, where tblA, tblB, and tblC are my tables and DBF-A, DBF-B, and DBF-C are my three DBF files.

CurrentDb.Execute "DELETE * FROM tblA"
DoCmd.TransferDatabase acImport, "dBase IV", "C:\Databases", acTable, "DBF-A", "tblA", False
CurrentDb.Execute "DELETE * FROM tblB"
DoCmd.TransferDatabase acImport, "dBase IV", "C:\Databases", acTable, "DBF-B", "tblB", False
CurrentDb.Execute "DELETE * FROM tblC"
DoCmd.TransferDatabase acImport, "dBase IV", "C:\Databases", acTable, "DBF-C", "tblC", False


Instead of writing the new data to the tblA, tblB, and tblC tables, Access creates 3 new tables:tblA1, tblB1, and tblC1.

I can't figure out why it is creating new tables when I am clearly asking it to import the data into the existing tables.

Anyone know what's going on here?


Duluter
 

WayPay

Registered User.
Local time
Today, 05:01
Joined
Nov 3, 2008
Messages
118
Did you try:
Code:
CurrentDb.Execute "DELETE * FROM tblA"
DoCmd.TransferDatabase acImport, "dBase IV", "C:\Databases\DBF-A.dbf", acTable, , "tblA", False
CurrentDb.Execute "DELETE * FROM tblB"
DoCmd.TransferDatabase acImport, "dBase IV", "C:\Databases\DBF-B.dbf", acTable, , "tblB", False
CurrentDb.Execute "DELETE * FROM tblC"
DoCmd.TransferDatabase acImport, "dBase IV", "C:\Databases\DBF-C.dbf", acTable, , "tblC", False
If all else fails, you can try:
Code:
CurrentDb.Execute "DROP TABLE tblA"
DoCmd.TransferDatabase acImport, "dBase IV", "C:\Databases", acTable, "DBF-A", "tblA", False
CurrentDb.Execute "DROP TABLE tblB"
DoCmd.TransferDatabase acImport, "dBase IV", "C:\Databases", acTable, "DBF-B", "tblB", False
CurrentDb.Execute "DROP TABLE tblB"
DoCmd.TransferDatabase acImport, "dBase IV", "C:\Databases", acTable, "DBF-C", "tblC", False
 

duluter

Registered User.
Local time
Yesterday, 22:01
Joined
Jun 13, 2008
Messages
101
WayPay:

Your first suggestion did not work--it says that it is not a valid path when I include the dbf file name with the path.

Your second suggestion worked perfectly. I don't have a problem dropping and recreating the tables because I'm dumping all the existing data anyway.

Thanks,

Duluter
 

Users who are viewing this thread

Top Bottom