Link to home
Start Free TrialLog in
Avatar of BrianBeck
BrianBeck

asked on

How to copy Access Table Structure using ADOX/ DAO

Hi Gurus

I need to know how to copy the structure of a given table in db_SOURCE to db_DEST.  Structure needs to include essential aspects such as field names, field type, field properties and index fields.

Your help is most appreciated.

Avatar of BrianBeck
BrianBeck

ASKER

It seems to me that a critical first step is to determine the specific attributes of each field in the source table.  I found the following resource which I'm sure will prove most useful:
http://www.thescripts.com/forum/thread189610.html
Avatar of rockiroads
Why cant u just issue a copy object?

Im assuming u are using VB and Access DB

I was thinking along the lines of this
Now if u copy an object, it should copy everything across for u

Public Sub CopyTable()

    Dim acc As Object
   
    Set acc = CreateObject("Access.Application")
    acc.OpenCurrentDatabase ("C:\mydb.mdb")
    acc.DoCmd.CopyObject , "db_DEST", acTable, "db_SOURCE"
    acc.CloseCurrentDatabase
    Set acc = Nothing
   
End Sub
Hi rockiroads

Thanks, but after experience I deliberately want to bypass Access and just make use of either ADOX or DAO.

I figure that with the above method of fetching field types, all I have to do is create a new table with the respective field names, types etc.  I expect to get to that stage within the day, and will update you.  If you have any suggestions, I most welcome them.

ok then. I guess u had some bad experiences using objects. And I thought I gave a easy answer :)
ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi rockiroads

Thanks, and timely.  I got my 'copy table structure' routine with handling field types, but hadnt done the indexes so your code is most handy.