By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,835 Members | 1,454 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,835 IT Pros & Developers. It's quick & easy.

Design Question -> Copying a table in another database, the relinking it.

P: n/a
Hi all,

I have a situation where I have a split database. At the back end, I
need to
- create a new table (I will call it newTable) with the exact fields,
and relationships as another table (let's call it oldTable, and I need
to copy everything EXCEPT the data).

- Then I need to delete oldTable, and rename newTable 'oldTable'

The problem is, that all of this happens at the back end, and I'm
having some problems making this work.

I've tried using CreateTableDef, and this creates the
definitions...but it never manages to actually create a table (that I
can see).

I've also tried the following SQL,
SELECT * INTO newTable FROM oldTable Where 0 = 1;

The 0=1 will never occur, thus I will have a new table with the proper
definitions, but no data...which is what I want. But this creates a
table at the front end :( I need a table at the back end which is
linked...

Anyone have any ideas?

Mark

Jul 13 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Copy oldTable. Paste. When you paste you will be given three options. One
will allow you to copy the structure only.
Easier though to open the oldTable, press Ctrl+a and then press delete.
Voila! All the data is gone and you have a blank oldTable.

mark_aok wrote:
>Hi all,

I have a situation where I have a split database. At the back end, I
need to
- create a new table (I will call it newTable) with the exact fields,
and relationships as another table (let's call it oldTable, and I need
to copy everything EXCEPT the data).

- Then I need to delete oldTable, and rename newTable 'oldTable'

The problem is, that all of this happens at the back end, and I'm
having some problems making this work.

I've tried using CreateTableDef, and this creates the
definitions...but it never manages to actually create a table (that I
can see).

I've also tried the following SQL,
SELECT * INTO newTable FROM oldTable Where 0 = 1;

The 0=1 will never occur, thus I will have a new table with the proper
definitions, but no data...which is what I want. But this creates a
table at the front end :( I need a table at the back end which is
linked...

Anyone have any ideas?

Mark
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200707/1

Jul 13 '07 #2

P: n/a
On Jul 13, 11:10 am, "jahoobob via AccessMonster.com" <u12179@uwe>
wrote:
Copy oldTable. Paste. When you paste you will be given three options. One
will allow you to copy the structure only.
Easier though to open the oldTable, press Ctrl+a and then press delete.
Voila! All the data is gone and you have a blank oldTable.

mark_aok wrote:
Hi all,
I have a situation where I have a split database. At the back end, I
need to
- create a new table (I will call it newTable) with the exact fields,
and relationships as another table (let's call it oldTable, and I need
to copy everything EXCEPT the data).
- Then I need to delete oldTable, and rename newTable 'oldTable'
The problem is, that all of this happens at the back end, and I'm
having some problems making this work.
I've tried using CreateTableDef, and this creates the
definitions...but it never manages to actually create a table (that I
can see).
I've also tried the following SQL,
SELECT * INTO newTable FROM oldTable Where 0 = 1;
The 0=1 will never occur, thus I will have a new table with the proper
definitions, but no data...which is what I want. But this creates a
table at the front end :( I need a table at the back end which is
linked...
Anyone have any ideas?
Mark

--
Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/2007...
I'm really sorry, I forgot to mention that I need to do this using
VBA.

So far I have code to copy the table definitions, but the problem is
copying the relationships. I know how to do this manually, and I
could easily tell my users how to do this, but it would be MUCH more
conveniant, if there was a way to copy a table's relationships into
the new table. This is the part that's killing me right now.

Mark

Jul 13 '07 #3

P: n/a
As jahoobob said, why don't you just delete each and every record on
oldTable?

The final result will be the same as if you created a new empty table,
dropped the old full table and renamed the new empty table to "old",
won't it?
On Jul 13, 12:39 pm, mark_aok <mark_...@hotmail.comwrote:
On Jul 13, 11:10 am, "jahoobob via AccessMonster.com" <u12179@uwe>
wrote:


Copy oldTable. Paste. When you paste you will be given three options. One
will allow you to copy the structure only.
Easier though to open the oldTable, press Ctrl+a and then press delete.
Voila! All the data is gone and you have a blank oldTable.
mark_aok wrote:
>Hi all,
>I have a situation where I have a split database. At the back end, I
>need to
>- create a new table (I will call it newTable) with the exact fields,
>and relationships as another table (let's call it oldTable, and I need
>to copy everything EXCEPT the data).
>- Then I need to delete oldTable, and rename newTable 'oldTable'
>The problem is, that all of this happens at the back end, and I'm
>having some problems making this work.
>I've tried using CreateTableDef, and this creates the
>definitions...but it never manages to actually create a table (that I
>can see).
>I've also tried the following SQL,
>SELECT * INTO newTable FROM oldTable Where 0 = 1;
>The 0=1 will never occur, thus I will have a new table with the proper
>definitions, but no data...which is what I want. But this creates a
>table at the front end :( I need a table at the back end which is
>linked...
>Anyone have any ideas?
>Mark
--
Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/2007...

I'm really sorry, I forgot to mention that I need to do this using
VBA.

So far I have code to copy the table definitions, but the problem is
copying the relationships. I know how to do this manually, and I
could easily tell my users how to do this, but it would be MUCH more
conveniant, if there was a way to copy a table's relationships into
the new table. This is the part that's killing me right now.

Mark- Hide quoted text -

- Show quoted text -

Jul 13 '07 #4

P: n/a
I have a situation where I have a split database. At the back end, I
need to
- create a new table (I will call it newTable) with the exact fields,
and relationships as another table (let's call it oldTable, and I need
to copy everything EXCEPT the data).
This doesn't sound logical as multiple users may need to perform this same
action at the same time, which is impossible this way. What exactly is it
that you're trying to achieve? There may be a better solution.

john
"mark_aok" <ma******@hotmail.comschreef in bericht
news:11**********************@q75g2000hsh.googlegr oups.com...
Hi all,

I have a situation where I have a split database. At the back end, I
need to
- create a new table (I will call it newTable) with the exact fields,
and relationships as another table (let's call it oldTable, and I need
to copy everything EXCEPT the data).

- Then I need to delete oldTable, and rename newTable 'oldTable'

The problem is, that all of this happens at the back end, and I'm
having some problems making this work.

I've tried using CreateTableDef, and this creates the
definitions...but it never manages to actually create a table (that I
can see).

I've also tried the following SQL,
SELECT * INTO newTable FROM oldTable Where 0 = 1;

The 0=1 will never occur, thus I will have a new table with the proper
definitions, but no data...which is what I want. But this creates a
table at the front end :( I need a table at the back end which is
linked...

Anyone have any ideas?

Mark

Jul 13 '07 #5

P: n/a
On Jul 13, 1:25 pm, "John" <j...@hn.comwrote:
I have a situation where I have a split database. At the back end, I
need to
- create a new table (I will call it newTable) with the exact fields,
and relationships as another table (let's call it oldTable, and I need
to copy everything EXCEPT the data).

This doesn't sound logical as multiple users may need to perform this same
action at the same time, which is impossible this way. What exactly is it
that you're trying to achieve? There may be a better solution.

john

"mark_aok" <mark_...@hotmail.comschreef in berichtnews:11**********************@q75g2000hsh.g ooglegroups.com...
Hi all,
I have a situation where I have a split database. At the back end, I
need to
- create a new table (I will call it newTable) with the exact fields,
and relationships as another table (let's call it oldTable, and I need
to copy everything EXCEPT the data).
- Then I need to delete oldTable, and rename newTable 'oldTable'
The problem is, that all of this happens at the back end, and I'm
having some problems making this work.
I've tried using CreateTableDef, and this creates the
definitions...but it never manages to actually create a table (that I
can see).
I've also tried the following SQL,
SELECT * INTO newTable FROM oldTable Where 0 = 1;
The 0=1 will never occur, thus I will have a new table with the proper
definitions, but no data...which is what I want. But this creates a
table at the front end :( I need a table at the back end which is
linked...
Anyone have any ideas?
Mark
Hey, the purpose of this is to uncorrupted the database. I have
written code which takes the contents of a table, and copies the non-
corrupted data to a new table. But to do so, I needed to copy the
relationships, and the definition of the table first.

Thanks for everyone's input, but I think I'm on the right track now.
It turns out DAO has everything needed
DAO.relationship, and Database.Relationships contain pretty much
everything I need. Thanks for all the input though,

Mark

Jul 13 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.