"Rob" <(E-Mail Removed)> wrote in message
news:6099D0A8-26C7-48C3-A7DC-(E-Mail Removed)...
>
> I think you would want to do this for the same reason one records Excel
> macros, then alters that code to fit one's true needs: it's a lot easier
> to
> build a table using the GUI than with a CREATE TABLE statement. And if
> you
> have situations, as I do, where tables are frequently built by importing
> Excel data ranges, it would be nice to be able to duplicate the structure
> of
> the data as the TransferSpreadsheet routine understands it.
>
> I just want to be able to store the table structure of built tables in
> code
> so that I can drop and re-create tables easily.
Access tables and the fields in them have properties that you can't set via
SQL. If you want to copy all attributes of the table, you can do it in a
couple of ways. One simple one is to use TransferDatabase, specifying the
current database as the source for an import. For example:
DoCmd.TransferDatabase _
acImport, "Microsoft Access", CurrentDb.Name, _
acTable, "Table1", "Table1_Copy",
True
It is also possible to copy the table via DAO, but the process is quite
involved. There is code posted in the Microsoft KB somewhere for doing
this.
--
Dirk Goldgar, MS Access MVP
Access tips:
www.datagnostics.com/tips.html
(please reply to the newsgroup)