VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Code will remove all tables in an MS Access database. Make sure to set a reference to the MS DAO 3.

by Brandon (46 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Thu 1st March 2007
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Code will remove all tables in an MS Access database. Make sure to set a reference to the MS DAO 3.6 Object Library.

API Declarations


'in the debugger window.
'all your tables in your database will now be gone!!!!!

Public db As Database
Public rst As Recordset
Public tdf As TableDef
Public tdfs As TableDefs


Rate Code will remove all tables in an MS Access database. Make sure to set a reference to the MS DAO 3.



Set db = CurrentDb()
Set tdfs = db.TableDefs
For Each tdf In tdfs
    If Left(tdf.Name, 4) <> "Msys" Then 'cannot delete system table names
        DoCmd.DeleteObject acTable, tdf.Name
    End If
Next tdf
tdfs.Refresh
db.Close
MsgBox "All tables have now been deleted!", vbExclamation, "Delete"
Set tdfs = Nothing 'destroy references to objects.
Set db = Nothing
End Sub


Download this snippet    Add to My Saved Code

Code will remove all tables in an MS Access database. Make sure to set a reference to the MS DAO 3. Comments

No comments have been posted about Code will remove all tables in an MS Access database. Make sure to set a reference to the MS DAO 3.. Why not be the first to post a comment about Code will remove all tables in an MS Access database. Make sure to set a reference to the MS DAO 3..

Post your comment

Subject:
Message:
0/1000 characters