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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying Access tables from one db to another

Status
Not open for further replies.

MangroBongacello

Programmer
Mar 20, 2001
189
0
0
SI
I need a routine, that would copy some of the tables from one Access database to another. How to go about it?

Thanks for any help
Mangro
 
Hi Mangro,

I have this for you if its any help. It was written to move all the table from one access db to another db.

Dim dbSource As Database
Dim wrkDefault As Workspace
Dim strSourceFile As String
Dim i As Integer
Dim y As Integer
strSourceFile = "Convdata.mdb"
' Get default Workspace.
Set wrkDefault = DBEngine.Workspaces(0)
Set dbSource = wrkDefault.OpenDatabase(strSourceFile)
i = 0
For Each tbl In dbSource.TableDefs
If (tbl.Attributes And dbSystemObject) = 0 Then
i = i + 1
End If
Next tbl
y = 0
For Each tbl In dbSource.TableDefs
If (tbl.Attributes And dbSystemObject) = 0 Then
DoCmd.TransferDatabase acImport, "Microsoft Access", strSourceFile, acTable, tbl.Name, tbl.Name, 0
y = y + 1
End If
Next tbl
dbSource.Close

Gazzza
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top