CheekyCharli
10-02-2008, 01:38 AM
Hi guys,
I'm afraid I'm a classic Access VBA joker - learned in Excel and making a bumpy transition.
I have this code, which, in my mind, should work - I littered it with debug.print commands whilst I built it and it's definitely identifying the right (user created tables in the current database). My problem is that it tells me the created database is in use when I try to copy the tables into it.
What am I missing?
Thanks in advance
Sub copytables()
Dim cOpieddBase As Database
Dim tDef As TableDef
Set cOpieddBase = CreateDatabase(Left(CurrentDb.Name, Len(CurrentDb.Name) - 4) & "copy.mdb", dbLangGeneral)
For Each tDef In CurrentDb.TableDefs
If tDef.Attributes = 0 Then DoCmd.CopyObject cOpieddBase.Name, , acTable, tDef.Name
Next tDef
End Sub
I'm afraid I'm a classic Access VBA joker - learned in Excel and making a bumpy transition.
I have this code, which, in my mind, should work - I littered it with debug.print commands whilst I built it and it's definitely identifying the right (user created tables in the current database). My problem is that it tells me the created database is in use when I try to copy the tables into it.
What am I missing?
Thanks in advance
Sub copytables()
Dim cOpieddBase As Database
Dim tDef As TableDef
Set cOpieddBase = CreateDatabase(Left(CurrentDb.Name, Len(CurrentDb.Name) - 4) & "copy.mdb", dbLangGeneral)
For Each tDef In CurrentDb.TableDefs
If tDef.Attributes = 0 Then DoCmd.CopyObject cOpieddBase.Name, , acTable, tDef.Name
Next tDef
End Sub