Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003
    Location
    Danbury,ct 06801
    Posts
    24

    Unanswered: delete all table from "A" database

    hi

    every 1

    i would like to delete all table's from database "A".. but i am not sure that i sould use Query or code...

    help pl...

    if there a Query or out then can u pl give me a EXAMPLE .

    thanks

    Hiten

  2. #2
    Join Date
    Dec 2003
    Posts
    268
    You can delete a table from a DB using the following command:

    DoCmd.DeleteObject acTable, "tablename"

    If you would like to delete all tables in the DB, then simply do a for next loop.

    To do the loop you will need to add a reference to the ADO library, then the following code should work:

    Dim tbl As TableDef
    Dim db As Database

    Set db = CurrentDb

    For Each tbl In db.TableDefs
    If Left(tbl.Name, 4) <> "MSys" Then
    DoCmd.DeleteObject acTable, tbl.Name
    End If
    Next tbl

    the if statement is in there becuase the DB will not allow you to delete its protected system tables that are hidden.

    This should work.

    If you have any questions let me know.
    mweyland at mnqio dot sdps dot org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •