Re: strange behavior by deleting tables
- From: Paul Clement <UseAdddressAtEndofMessage@xxxxxxxxxxxxxx>
- Date: Mon, 09 Apr 2007 08:10:53 -0500
On Thu, 5 Apr 2007 23:39:27 +0200, "Cesar Romani" <cesar_romani@xxxxxxxx> wrote:
¤ 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?
ADOX operates a bit differently than Access or DAO. It's possible that it may be discriminating
between a TABLE and a VIEW. I would dump out all the table names and their corresponding types in
order to verify whether this is the case.
Paul
~~~~
Microsoft MVP (Visual Basic)
.
- References:
- strange behavior by deleting tables
- From: Cesar Romani
- strange behavior by deleting tables
- Prev by Date: Re: looking for the Access equivalent of the CASE WHEN SQL Server operator in query
- Next by Date: SQL Statement to to retirve table names
- Previous by thread: Re: strange behavior by deleting tables
- Next by thread: Re: Command Object Page Size
- Index(es):
Relevant Pages
|