VB & VBA - Copy Table Structure Only
Greetings all, my first post on this forum
My question relates to "code wise" copying of the structure of a table.
Actually, more completely, what I need to do is to refresh a table with data from 2 fixed length text files.
My first 3 concepts, I don't like:
1. Delete the table and programmatically recreate it with tabledef, createindex, createfield.... etc. This is fast, but A lot of code for what should be a simple process.
2. Select ...into table... with the select being a criteria that would select nothing.
3. accessing the table. selecting all the rows and deleting them.
These second two options are simple, but SLOW!!!
If I was to do this manually, I would ...
1. rename the table
2. Copy the table
3. Paste special/Structure only.
This is fast and simple...but manual...I need to do it programmactically.
and then use the code to populate the table from the txt files.
Does anyone know the "Simple" and "fast" way of completing this task?
Thanks
Michael
Re: VB & VBA - Copy Table Structure Only
I have a DB on SQL server 2008 R2. On my laptop I only have Access 2007. I would like to create an Access Back end so that I can develop on holiday
If you use the SQL server Copy Wizard you lose the Primary Key and Identity
( there is supposed to be Enable Identity option but it does not appear for me)
If in Access you Import the tables you get the IDENTITY ( Autonumber) but lose the primary key
If in Access you copy a linked table ( Structure and Data) you get the Primary key and the Identity. But you have to do that manually - I have over 100 tables
The TransferDatabase copies a linked table to a linked table
So does CopyObject.
Is there an easy solution?