472,107 Members | 1,234 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,107 software developers and data experts.

Copy all tables from one database to another

If I wanted to be able to copy all of the tables in an existing database
called Original.mde to another database called New.mde from a button click
event in Original.mde, is there an easy way of coding it without naming
every single table in Original.mde. I am looking for a way of updating a
database on site without needing to access the database window and import
the existing tables into a new empty database.

dixie
Nov 12 '05 #1
11 12471
On Wed, 25 Feb 2004 15:37:43 +1100, "dixie" <di****@dogmail.com>
wrote:

Not sure why you're not just making a copy of the database. But that
aside, you can walk the TableDefs collection to find the names of all
tables.

-Tom.

If I wanted to be able to copy all of the tables in an existing database
called Original.mde to another database called New.mde from a button click
event in Original.mde, is there an easy way of coding it without naming
every single table in Original.mde. I am looking for a way of updating a
database on site without needing to access the database window and import
the existing tables into a new empty database.

dixie


Nov 12 '05 #2
Loop through the TableDefs collection and export each table... ?
--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response

"dixie" <di****@dogmail.com> wrote in message
news:zF****************@nnrp1.ozemail.com.au...
If I wanted to be able to copy all of the tables in an existing database
called Original.mde to another database called New.mde from a button click
event in Original.mde, is there an easy way of coding it without naming
every single table in Original.mde. I am looking for a way of updating a
database on site without needing to access the database window and import
the existing tables into a new empty database.

dixie

Nov 12 '05 #3
"dixie" <di****@dogmail.com> wrote in news:zFV_b.174$ud3.2855
@nnrp1.ozemail.com.au:
If I wanted to be able to copy all of the tables in an existing database
called Original.mde to another database called New.mde from a button click
event in Original.mde, is there an easy way of coding it without naming
every single table in Original.mde. I am looking for a way of updating a
database on site without needing to access the database window and import
the existing tables into a new empty database.


SaveAsText 6, "", FileName

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #4
You couldn't give me an example of this I suppose.

dixie

"Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message
news:40******@nexus.comcen.com.au...
Loop through the TableDefs collection and export each table... ?
--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response

"dixie" <di****@dogmail.com> wrote in message
news:zF****************@nnrp1.ozemail.com.au...
If I wanted to be able to copy all of the tables in an existing database
called Original.mde to another database called New.mde from a button click event in Original.mde, is there an easy way of coding it without naming
every single table in Original.mde. I am looking for a way of updating a database on site without needing to access the database window and import the existing tables into a new empty database.

dixie


Nov 12 '05 #5
This is off the top of my head so I hope it works ok :)

dim myDB as TableDef
set myTD = CurrentDB.TableDefs
for i = 0 to (myTD.Count - 1)
InTable = myTD(i).Name
OutTable = myTD(i).Name
OutDB = "c:\out.mdb"
docmd.copyobject OutDB, InTable, acTable, OutTable
next

--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response
"dixie" <di****@dogmail.com> wrote in message
news:un****************@nnrp1.ozemail.com.au...
You couldn't give me an example of this I suppose.

dixie

"Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message
news:40******@nexus.comcen.com.au...
Loop through the TableDefs collection and export each table... ?
--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response

"dixie" <di****@dogmail.com> wrote in message
news:zF****************@nnrp1.ozemail.com.au...
If I wanted to be able to copy all of the tables in an existing database called Original.mde to another database called New.mde from a button click event in Original.mde, is there an easy way of coding it without naming every single table in Original.mde. I am looking for a way of
updating
a database on site without needing to access the database window and import the existing tables into a new empty database.

dixie



Nov 12 '05 #6
OK, thanks, I understand that. Am I Correct in presuming that this will not
bring the relationships with the tables? If not, is there a simple way of
doing it?

dixie

"Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message
news:s1******************@news-server.bigpond.net.au...
This is off the top of my head so I hope it works ok :)

dim myDB as TableDef
set myTD = CurrentDB.TableDefs
for i = 0 to (myTD.Count - 1)
InTable = myTD(i).Name
OutTable = myTD(i).Name
OutDB = "c:\out.mdb"
docmd.copyobject OutDB, InTable, acTable, OutTable
next

--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response
"dixie" <di****@dogmail.com> wrote in message
news:un****************@nnrp1.ozemail.com.au...
You couldn't give me an example of this I suppose.

dixie

"Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message
news:40******@nexus.comcen.com.au...
Loop through the TableDefs collection and export each table... ?
--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response

"dixie" <di****@dogmail.com> wrote in message
news:zF****************@nnrp1.ozemail.com.au...
> If I wanted to be able to copy all of the tables in an existing database > called Original.mde to another database called New.mde from a button

click
> event in Original.mde, is there an easy way of coding it without naming > every single table in Original.mde. I am looking for a way of

updating
a
> database on site without needing to access the database window and

import
> the existing tables into a new empty database.
>
> dixie
>
>



Nov 12 '05 #7
"dixie" <di****@dogmail.com> wrote in
news:Di***************@nnrp1.ozemail.com.au:
OK, thanks, I understand that. Am I Correct in presuming that this will
not bring the relationships with the tables? If not, is there a simple
way of doing it?


sigh ...

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #8
Wouldn't it be easier to just copy the entire file? It would preserve
the relationships...

Pavel

dixie wrote:

OK, thanks, I understand that. Am I Correct in presuming that this will not
bring the relationships with the tables? If not, is there a simple way of
doing it?

dixie

"Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message
news:s1******************@news-server.bigpond.net.au...
This is off the top of my head so I hope it works ok :)

dim myDB as TableDef
set myTD = CurrentDB.TableDefs
for i = 0 to (myTD.Count - 1)
InTable = myTD(i).Name
OutTable = myTD(i).Name
OutDB = "c:\out.mdb"
docmd.copyobject OutDB, InTable, acTable, OutTable
next

--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response
"dixie" <di****@dogmail.com> wrote in message
news:un****************@nnrp1.ozemail.com.au...
You couldn't give me an example of this I suppose.

dixie

"Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message
news:40******@nexus.comcen.com.au...
> Loop through the TableDefs collection and export each table... ?
> --
> Bradley
> Software Developer www.hrsystems.com.au
> A Christian Response www.pastornet.net.au/response
>
> "dixie" <di****@dogmail.com> wrote in message
> news:zF****************@nnrp1.ozemail.com.au...
> > If I wanted to be able to copy all of the tables in an existing

database
> > called Original.mde to another database called New.mde from a button
click
> > event in Original.mde, is there an easy way of coding it without

naming
> > every single table in Original.mde. I am looking for a way of

updating
a
> > database on site without needing to access the database window and
import
> > the existing tables into a new empty database.
> >
> > dixie
> >
> >
>
>


Nov 12 '05 #9
The rest of the database would have been updated (as in a new version with
some fix or new feature), so it is not practical to just copy the file.
What I want to do is to import the old tables into the new database, getting
their relationships too. I know I can do this with a manual File --> Get
external data --> import, but I am trying to do it without the user needing
to go to the database window.

dixie

"Pavel Romashkin" <pa*************@hotmail.com> wrote in message
news:40***************@hotmail.com...
Wouldn't it be easier to just copy the entire file? It would preserve
the relationships...

Pavel

dixie wrote:

OK, thanks, I understand that. Am I Correct in presuming that this will not bring the relationships with the tables? If not, is there a simple way of doing it?

dixie

"Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message
news:s1******************@news-server.bigpond.net.au...
This is off the top of my head so I hope it works ok :)

dim myDB as TableDef
set myTD = CurrentDB.TableDefs
for i = 0 to (myTD.Count - 1)
InTable = myTD(i).Name
OutTable = myTD(i).Name
OutDB = "c:\out.mdb"
docmd.copyobject OutDB, InTable, acTable, OutTable
next

--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response
"dixie" <di****@dogmail.com> wrote in message
news:un****************@nnrp1.ozemail.com.au...
> You couldn't give me an example of this I suppose.
>
> dixie
>
> "Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message
> news:40******@nexus.comcen.com.au...
> > Loop through the TableDefs collection and export each table... ?
> > --
> > Bradley
> > Software Developer www.hrsystems.com.au
> > A Christian Response www.pastornet.net.au/response
> >
> > "dixie" <di****@dogmail.com> wrote in message
> > news:zF****************@nnrp1.ozemail.com.au...
> > > If I wanted to be able to copy all of the tables in an existing
database
> > > called Original.mde to another database called New.mde from a button > click
> > > event in Original.mde, is there an easy way of coding it without
naming
> > > every single table in Original.mde. I am looking for a way of
updating
> a
> > > database on site without needing to access the database window and > import
> > > the existing tables into a new empty database.
> > >
> > > dixie
> > >
> > >
> >
> >
>
>

Nov 12 '05 #10
I can create each relationship in code separately, but I seem to remember
that if I, say, ask for Attributes = dbRelationUpdateCascade +
dbRelationDeleteCascade and that relationship fails because someone has
managed to delete records such that the referential integrity is destroyed,
then no relationship is formed at all. In this case, I would need a simple
relationship without referential integrity to be created. But, because the
database is not with me, but out on a site somewhere, I have no way of
checking if the referential integrity failed or not. Is there a simple way
of in code, creating a normal relationship if referential integrity fails?

dixie

"dixie" <di****@dogmail.com> wrote in message
news:q2****************@nnrp1.ozemail.com.au...
The rest of the database would have been updated (as in a new version with
some fix or new feature), so it is not practical to just copy the file.
What I want to do is to import the old tables into the new database, getting their relationships too. I know I can do this with a manual File --> Get
external data --> import, but I am trying to do it without the user needing to go to the database window.

dixie

"Pavel Romashkin" <pa*************@hotmail.com> wrote in message
news:40***************@hotmail.com...
Wouldn't it be easier to just copy the entire file? It would preserve
the relationships...

Pavel

dixie wrote:

OK, thanks, I understand that. Am I Correct in presuming that this will
not
bring the relationships with the tables? If not, is there a simple
way
of doing it?

dixie

"Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message
news:s1******************@news-server.bigpond.net.au...
> This is off the top of my head so I hope it works ok :)
>
> dim myDB as TableDef
> set myTD = CurrentDB.TableDefs
> for i = 0 to (myTD.Count - 1)
> InTable = myTD(i).Name
> OutTable = myTD(i).Name
> OutDB = "c:\out.mdb"
> docmd.copyobject OutDB, InTable, acTable, OutTable
> next
>
> --
> Bradley
> Software Developer www.hrsystems.com.au
> A Christian Response www.pastornet.net.au/response
>
>
> "dixie" <di****@dogmail.com> wrote in message
> news:un****************@nnrp1.ozemail.com.au...
> > You couldn't give me an example of this I suppose.
> >
> > dixie
> >
> > "Bradley" <br*****@REMOVETHIScomcen.com.au> wrote in message
> > news:40******@nexus.comcen.com.au...
> > > Loop through the TableDefs collection and export each table... ?
> > > --
> > > Bradley
> > > Software Developer www.hrsystems.com.au
> > > A Christian Response www.pastornet.net.au/response
> > >
> > > "dixie" <di****@dogmail.com> wrote in message
> > > news:zF****************@nnrp1.ozemail.com.au...
> > > > If I wanted to be able to copy all of the tables in an
existing > database
> > > > called Original.mde to another database called New.mde from a

button > > click
> > > > event in Original.mde, is there an easy way of coding it without > naming
> > > > every single table in Original.mde. I am looking for a way of
> updating
> > a
> > > > database on site without needing to access the database window and > > import
> > > > the existing tables into a new empty database.
> > > >
> > > > dixie
> > > >
> > > >
> > >
> > >
> >
> >
>
>


Nov 12 '05 #11
It sounds as if you don't have a split frontend-backend database. If
you did, there would never be any "new features", etc. in the
back-end, and all you have to do is provide the users with a new
front-end.

Regards,
Krisa
Lyle Fairfield <Mi************@Invalid.Com> wrote in message news:<Xn*******************@130.133.1.4>...
"dixie" <di****@dogmail.com> wrote in news:zFV_b.174$ud3.2855
@nnrp1.ozemail.com.au:
If I wanted to be able to copy all of the tables in an existing database
called Original.mde to another database called New.mde from a button click
event in Original.mde, is there an easy way of coding it without naming
every single table in Original.mde. I am looking for a way of updating a
database on site without needing to access the database window and import
the existing tables into a new empty database.


SaveAsText 6, "", FileName

Nov 12 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by lgbjr | last post: by
4 posts views Thread by JIM.H. | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.