Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying table using DAO

Status
Not open for further replies.

sonper

Programmer
Oct 4, 2001
94
PH
Hi guys!

I'm trying to copy an mdb to another mdb. I use the filecopy command but I'm getting error if the mdb is in use.
I tried to use the SELECT INTO statement in DAO and it worked but the primary are not copied. Can you please tell me how I can have an exact copy of an mdb.

I'm using VB6 and MS Access.

Thanks.
 
filecopy will work but you have to have the original mdb closed to copy it.

From memory Copyfile and (see filesystemobjects) can be used to copy regardless of whether it is in use or not. It is a bit convoluted.

You could also create a new table using the data from the original but this wont copy forms & queries
 
tedsmith,

Thanks for your reply. I would like to correct my posting it's primary key that I'm referring to when I say primary. Do you have an idea of a faster way to copy a large database say 100,000 records with 10 fields or append records from one db to another including attributes such as primary key, index, etc.

Also, how will I create a table with a primary key?

Thanks again.
 
Somewhere in the help there is a description of how to creat a table in visual basic code. You can also use this to modify the table after you have copied it and do things like add the field type or widths and set primary key to a field.
I used it years ago and it is something like when you want to add a field like this (only different!):-
Dim dbs As Database
Set dbs = OpenDatabase("c:\MyFolder\MyDatabase.MDB")
dbs.Execute "ALTER TABLE MyTable " & "ADD COLUMN InvoiceDate DATETIME;"
It's in the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top