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?

Thanks!

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.")

The above does not work for me, it raises an error every time i use Dim oAccess As New Microsoft.Office.Interop.Access.Application

YES I have the interop referenced in my project and yes my module imports Microsoft.Office.Interop.Access.Dao

Here is the error:

Retrieving the COM class factory for component with CLSID {73A4C9C1-D68D-11D0-98BF-00A0C90DC8D9} failed due to the following error: 80040154.

I am referencing Microsoft.Office.interop.access.dao 12.0 because many of my users are still on Office 2007. I have gotten the same error using a later version of Microsoft.Office.interop.access.dao as well.

I am using Visual Studio 2010 VB.NET and have Access 2013 installed on the system. I have searched the error code but continually receive information on that error associated with Word or Excel but not Access.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.