CopyObject When Destination File Might or Might Not Exist

C

Charles

Hi,

Can you tell me how I can copy an Access table to a different name, say
Table2 when there is possibly (or possibly not) already a Table2 and I want
to write over the old Table2 if it exists?

Thanks
 
D

Dirk Goldgar

Charles said:
Hi,

Can you tell me how I can copy an Access table to a different name, say
Table2 when there is possibly (or possibly not) already a Table2 and I
want
to write over the old Table2 if it exists?


You can use the TransferDatabase method instead of CopyObject. For example,

DoCmd.TransferDatabase acExport, _
"Microsoft Access", CurrentDb.Name, _
acTable, "Table1", "Table2"

.... will copy Table1 to Table2 in the current database, replacing Table2 if
it exists.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top