Copy a table and rename the table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I splitted my database and put the backend on the Network. I would like to
know how can I copy my table called ,"EXAMPLE", from my database called
"DATA", and place the table in a nonexisting database which will be renamed
according to the current day, then place it in I:\DATA\? For example, I would
like "EXAMPLE" table to be copied , but the new database would be named
"DE20060925". "DE" would remain the same;however, the date would change
daily. I don't want the new database to be saved but once daily. All this
would be done by clicking on a button. Can you help me w/ some VBA to get
this accomplished?
 
Lavatress said:
I splitted my database and put the backend on the Network. I would
like to know how can I copy my table called ,"EXAMPLE", from my
database called "DATA", and place the table in a nonexisting database
which will be renamed according to the current day, then place it in
I:\DATA\? For example, I would like "EXAMPLE" table to be copied ,
but the new database would be named "DE20060925". "DE" would remain
the same;however, the date would change daily. I don't want the new
database to be saved but once daily. All this would be done by
clicking on a button. Can you help me w/ some VBA to get this
accomplished?

You can create the new database with this:

Dim dbNew As DAO.Database

Set dbNew = _
DBEngine.CreateDatabase( _
"I:\DATA\DE" & Format(Date, "yyyymmdd"), _
dbLangGeneral)

How you copy the table depends on where the table is, where the code is
running, and whether you want to copy every aspect of the table
(indexes, default values, special field properties, etc.), or just the
data that is in it. Could you clarify that, please?
 
The table is in my main database called, "DATA.mdb". I have a button on my
main switchboard form that has code behind it. I would like to copy the
tables' structure and data.
 
Lavatress said:
The table is in my main database called, "DATA.mdb". I have a button
on my main switchboard form that has code behind it. I would like to
copy the tables' structure and data.

Is that main database the one in which the code is running, or is that a
back-end database, while the code is running in the front-end, which is
linked to DATA.mdb. I'm guessing the latter is the case, but it makes a
major difference to the code, so I want to make sure.
 
Back
Top