Create DBF from code?

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

Hi,

In Access 2002 I need to output a DBF file from VB code.
I was planning to create a temporary table, then use the
TransferDatabase action. However, it seems this action
requires the DBF file to be existing.

Is there any way to output a table (or a recordset or
whatever) to a new DBF database via code?

I know that it can be done by the user. The export
function can create a new DBF database.

I tried using: DoCmd.RunCommand acCmdExport

....but that just brings up the export dialog. I need for
this to be totally automated.

Please help!!! Thanks.

Tim
 
yes, i also found it bit complicated
how you can make it:
- make an empty dbf file, structure only. we call it template file
- user enter where to save dbf, we copy template into user location
- now you can either run docmd.transferdatabase to this new dbf file, or use
append query on linked new dbf file
 
Tim,

The instructions in Help are a bit less than clear, but you can create a new
DBF file using TransferDatabase; for example:

DoCmd.TransferDatabase acExport, "dBase III", "c:\FullPath\", acTable,
"AccessTableName", "AcctMgr.dbf"

hth,
 
Oh! Thank you Cheryl. This works!

I would say that the documentation is downright wrong.
The parameter where you put "c:\FullPath\" is specified
as...

"DatabaseName Optional Variant. A string expression
that's the full name, including the path, of the database
you want to use to import, export, or link data."

Huh? This is just wrong. Should be called "Pathname" or
something.

The parameter where you put "AcctMgr.dbf" is specified
as...

"Destination Optional Variant. A string expression that's
the name of the imported, exported, or linked object in
the destination database."

Huh again? Should be called "Filename" or something.

Anyway, thanks!!!

Tim
 
Back
Top