Rich P <rp*****@aol.comwrote in
news:lO***************@news.uswest.net:
I was not able to drop a table in a foreign DB using sql, but I
was able to do it using DAO code:
-----------------------------------------------
Dim db As DAO.Database, tdf As TableDef
Set db = DBEngine.OpenDatabase("C:\CodeTest\db2test.mdb")
For Each tdf In db.TableDefs
If tdf.Name = "tblxyz942" Then
db.TableDefs.Delete tdf.Name
Exit For
End If
Next
--------------------------------------------------
Why not just do this:
Set db = DBEngine.OpenDatabase("C:\CodeTest\db2test.mdb")
db.TableDefs.Delete "tblxyz942"
Why the For/Each loop?
The only reason I can think of would be to avoid an error, but the
error is easily trapped for.
On the other hand, your method does have the beauty of avoiding
raising an error, which I consider a good thing.
On the issue of DDL, I can't see why you couldn't execute DDL SQL to
drop a table in a foreign database using DAO, or just using an IN
'[database path/name]' clause using the local database object.
--
David W. Fenton
http://www.dfenton.com/
usenet at dfenton dot com
http://www.dfenton.com/DFA/