tags:

views:

22

answers:

1

Anyway to Erase multiple forms, queries, etc in Access 2000? (In the designer that is).

A: 

You can delete objects with VBA. Be sure to step backwards when deleting from a collection, for example, this code will delete quite a few objects:

Dim db As Database
Dim idx As Long
Dim strName As String

Set db = CurrentDb

    ''Forms
    For idx = CurrentProject.AllForms.Count - 1 To 0 Step -1
        strName = CurrentProject.AllForms(idx).Name
        DoCmd.DeleteObject acForm, strName
    Next idx

    ''Reports
    For idx = CurrentProject.AllReports.Count - 1 To 0 Step -1
        strName = CurrentProject.AllReports(idx).Name
        DoCmd.DeleteObject acReport, strName
    Next idx

    ''Modules
    For idx = CurrentProject.AllModules.Count - 1 To 0 Step -1
        strName = CurrentProject.AllModules(idx).Name
        If strName <> "Module9" Then
            DoCmd.DeleteObject acModule, strName
        End If
    Next idx

    ''Queries
    For idx = db.QueryDefs.Count - 1 To 0 Step -1
        strName = db.QueryDefs(idx).Name
        If Left(strName, 4) <> "~sq_" Then
            db.QueryDefs.Delete strName
        Else
            Debug.Print strName
        End If
    Next idx

    ''Relationships
    For idx = db.Relations.Count - 1 To 0 Step -1
        strName = db.Relations(idx).Name

        If Left(strName, 4) <> "msys" Then
            db.Relations.Delete strName
        Else
            Debug.Print strName
        End If
    Next idx

    ''Tables
    For idx = db.TableDefs.Count - 1 To 0 Step -1
        strName = db.TableDefs(idx).Name
        If Left(strName, 4) <> "msys" Then
            db.TableDefs.Delete strName
        Else
            Debug.Print strName
        End If
    Next idx
Remou