PC Review


Reply
Thread Tools Rate Thread

How do I copy only the structure of a table?

 
 
Margaret Bartley
Guest
Posts: n/a
 
      4th Jul 2005
The DoCmd.CopyObject method does not have an argument that flags whether to
copy all the data, or just the structure. Is there a way in VBA code to
copy only the structure of a table, and not the data?

Many thanks,
Margaret


 
Reply With Quote
 
 
 
 
Alex Dybenko
Guest
Posts: n/a
 
      4th Jul 2005
Hi,
perhaps you can first copy whole table, and then delete data.
other option - you have to write a code to go throught all fields,
properties, indexes, etc of a table and create same on a new one

--
Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com


"Margaret Bartley" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> The DoCmd.CopyObject method does not have an argument that flags whether
> to copy all the data, or just the structure. Is there a way in VBA code
> to copy only the structure of a table, and not the data?
>
> Many thanks,
> Margaret
>



 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      4th Jul 2005
"Margaret Bartley" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)
> The DoCmd.CopyObject method does not have an argument that flags
> whether to copy all the data, or just the structure. Is there a way
> in VBA code to copy only the structure of a table, and not the data?


DoCmd.TransferDatabase will do it. Just specify the current database's
name as the target database, and specify True for the StructureOnly
argument. For example,

DoCmd.TransferDatabase _
acExport, _
"Microsoft Access", _
CurrentDb.Name, _
acTable, _
"Table1", _
"Table1_COPY", _
True

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      4th Jul 2005
"Alex Dybenko" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)
> Hi,
> perhaps you can first copy whole table, and then delete data.
> other option - you have to write a code to go throught all fields,
> properties, indexes, etc of a table and create same on a new one


There's a Microsoft KnowledgeBase article for Access 97 on how to do
this with DAO:

http://support.microsoft.com/default...b;en-us;217011

I don't think there's a version of the article for Access 2000+, but I
imagine that article would work for these versions, too. However, using
TransferDatabase seems simplest.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
Margaret Bartley
Guest
Posts: n/a
 
      10th Jul 2005
Ooh, Thank You!!

"Dirk Goldgar" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Margaret Bartley" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)
>> The DoCmd.CopyObject method does not have an argument that flags
>> whether to copy all the data, or just the structure. Is there a way
>> in VBA code to copy only the structure of a table, and not the data?

>
> DoCmd.TransferDatabase will do it. Just specify the current database's
> name as the target database, and specify True for the StructureOnly
> argument. For example,
>
> DoCmd.TransferDatabase _
> acExport, _
> "Microsoft Access", _
> CurrentDb.Name, _
> acTable, _
> "Table1", _
> "Table1_COPY", _
> True
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Table - Structure Only =?Utf-8?B?QnJhZA==?= Microsoft Access VBA Modules 3 6th Dec 2005 08:58 PM
Copy structure table BB Microsoft Access 7 24th Jun 2005 01:27 PM
copy fields from one table to the field structure of another table Educo Gent Microsoft Access ADP SQL Server 2 10th Feb 2005 05:29 PM
Copy Table Structure Tom Microsoft Access Getting Started 4 7th Jul 2003 05:13 PM
Copy Table Structure Tom Microsoft Access Form Coding 2 7th Jul 2003 03:27 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:38 AM.