I am trying to copy an entire table (fields and records) from a different database. I used the same code to copy a query and it worked, however for a table it is not working at all. Below is my code, can you please try to figure out where I am going wrong. Also, is there a way to auto-allign the code?
Note: "H:\Projects\ReliaBuilder\Jeff's Screw around files\Bill Duncan\heater + #.mdb" = Location of desired database
"criticality" = name of desired table
Sub ImportTable()
Dim ThisDb As Database, ThatDB As Database
Dim NewTabl As TableDef
Dim DbName As String
Dim ThatTabl As TableDef
'Database with desired table
DbName = "H:\Projects\ReliaBuilder\Jeff's Screw around files\Bill Duncan\heater + #.mdb"
Set ThisDb = CurrentDb()
Set ThatDB = DBEngine.Workspaces(0).OpenDatabase(DbName)
'desired table
Set ThatTabl = ThatDB.TableDefs("criticality")
Set NewTabl = ThisDb.CreateTableDef(ThatTabl.Name, ThatTabl.Attributes)
End Sub
Note: "H:\Projects\ReliaBuilder\Jeff's Screw around files\Bill Duncan\heater + #.mdb" = Location of desired database
"criticality" = name of desired table
Sub ImportTable()
Dim ThisDb As Database, ThatDB As Database
Dim NewTabl As TableDef
Dim DbName As String
Dim ThatTabl As TableDef
'Database with desired table
DbName = "H:\Projects\ReliaBuilder\Jeff's Screw around files\Bill Duncan\heater + #.mdb"
Set ThisDb = CurrentDb()
Set ThatDB = DBEngine.Workspaces(0).OpenDatabase(DbName)
'desired table
Set ThatTabl = ThatDB.TableDefs("criticality")
Set NewTabl = ThisDb.CreateTableDef(ThatTabl.Name, ThatTabl.Attributes)
End Sub