I have an existing table in an Access DB that I want my user to be able to copy by pressing a button. When the user presses the button, they should be prompted for what is to be the name of the table. The program should then copy the existing table into the Access DB with the new name, and add the new table's name to a combobox showing the list of tables in the DB including the new one. Of course, this new table will need to show up in my dataset as well so I can use the data the user will plug into the new table.

Can anyone get me started on how to copy the Access table and have it show up in my dataset?


Never mind, I found some code. If anyone needs it, here it is:

Dim oAccess As New Microsoft.Office.Interop.Access.Application
        ''Open a database
        oAccess.OpenCurrentDatabase("F:\My Projects\RIS 2010\Squirrel2\Application\WindowsApplication1\WindowsApplication1\App_Data\tablecopy.accdb", _
                                    False, "woodkitten70")
        ''"Import" table 
        oAccess.DoCmd.TransferDatabase(Microsoft.Office.Interop.Access.AcDataTransferType.acExport, "Microsoft Access", _
                                       "F:\My Projects\RIS 2010\Squirrel2\Application\WindowsApplication1\WindowsApplication1\App_Data\tablecopy.accdb", _
                                        Microsoft.Office.Interop.Access.AcObjectType.acTable, "Threshold market: default", "newtable1", False, False)
        MsgBox("Data table copied.")
This question has already been answered. Start a new discussion instead.