strange behavior by deleting tables



I've written the following code to delete all tables of a ms access db.
It deletes only half the number of tables not all.
----------------------------------------
1. Sub deleteTables()
2. Dim cat As New ADOX.Catalog
3. Dim tbl As ADOX.Table
4.
5. cat.ActiveConnection = CurrentProject.Connection
6.
7. For Each tbl In cat.Tables
8. If tbl.Type = "TABLE" Then
9. cat.Tables.Delete tbl.Name
10. End If
11. Next
12.
13. Set tbl = Nothing: Set cat = Nothing
14. End Sub
------------------------------------------
If I change the line 9. with
DoCmd.DeleteObject acTable, tbl.Name
the modified code deletes all tables. Why is it so?

Many thanks in advance,
Cesar


.



Relevant Pages