VB Code to copy linked table to local

J

JD

I have an Access 2007 database with a linked ODBC table that changes on a
daily basis. I want to automate a function where the linked table is copied
and pasted as a local table. I tried the following command:

DoCmd.CopyObject , stNewName, acTable, stTblName

It worked, and named the new table correctly (based on an earlier command
that assigns the table name with the current date as "stNewName"), but it
stayed as a linked table - which means tomorrow, today's data will be lost.
Is there a parameter of the CopyObject command that will make the new table
local, or is there another command I should be using?
 
K

kc-mass

Why not use a MakeTable query to create your file.

Something like :

SELECT tblLinkedTable.* INTO tblCopyOfLinkedFile
FROM tblLinkedTable;

If you use VBA can can easily embed the date in the target filename so
each day's will be retained and ID'd.

Regards

Kevin
 
D

Daniel Pineault

J

JD

Thanks for the help. It seems to me that based on the suggestions I've read,
the easiest solution will be to simply copy the table and paste it to a new
local table.
 
S

Stefan Hoffmann

hi JD,

It worked, and named the new table correctly (based on an earlier command
that assigns the table name with the current date as "stNewName"), but it
stayed as a linked table - which means tomorrow, today's data will be lost.
Is there a parameter of the CopyObject command that will make the new table
local, or is there another command I should be using?
See

http://msdn.microsoft.com/en-us/library/bb214131.aspx

DoCmd.TransferDatabase acImport, ....


It's faster then using SELECT * INTO localTable FROM linkedTable.


mfG
--> stefan <--
 

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