Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy Access Table Structure to a New Table DAO

Status
Not open for further replies.

Trob70

Programmer
Sep 25, 2012
89
AU
I need to Create a new Table in an Access Database Copying the Structure of an existing Table
The sql i have created is..


Dim db As DAO.Database
Dim MyQry As DAO.QueryDef
Sql = "CREATE TABLE Data2 AS SELECT * From Data1 WHERE 1= 2"

Really appreciate some help with the above code .

Regards Trob70

 
All ok Have worked it out...

Sql = "SELECT * INTO Data2 FROM Data1 WHERE 1 = 2"
Set cnns = OpenDatabase(vmdb)
cnns.Execute Sql
cnns.Close

Regards Trob70
 
Just keep in mind this method does not copy other attributes of your source table - no indexes (including Primary Key) or foreign key constraints (if you're into that kinda thing), etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top