2
votes

How can I export a single table as a dBase 5 file through VBA?

Currently I am using this VBA code:

DoCmd.TransferDatabase _
acExport, _
"dBase IV", _
"DB_Total", _
acTable, _
"DB_Total", _
"C:\Data", _
False

But when I try to execute this code, I get the following error (in dutch, so roughly translated):

"DB_Total is not a valid path"

But I'm not really sure what the path is, because the table I am trying to export is inside the Access file, right?

1
According to the docs you should need the full path to the output database in the 4th parameter: DoCmd.TransferDatabase acExport, "dBase IV", "c:\full\path\to\output.dbf", acTable, "TableNameInAccess", "Output.dbf", False, False - Dan Metheus
This seems to work, but my file gets saved as " C__DATA_.DBF " , Is there any way for me to change that ? - Gutanoth
@DanMetheus you should post your answer, Gutanoth, you must set the proper argument to the name you want, as Dan says, DoCmd.TransferDatabase _ acExport, _ "dBase IV", _ "C:\Data", _ acTable, _ "DB_Total", _ "DB_Total", _ False See msdn.microsoft.com/en-us/library/office/ff196455.aspx - Fionnuala

1 Answers

3
votes

You should need the full path to the output database in the 4th parameter:

 DoCmd.TransferDatabase acExport, "dBase IV", "c:\full\path\to\output", acTable, "TableNameInAccess", "DBFTable", False, False

Also I believe you will have to limit your output (DBFTable) to 8 or fewer characters because it is dBase IV.