Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Sep 2002
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete but one (Access 2000)

    How could i mend the following function to delete all modules except module MdlBas ?
    Private Function DeleteAllModules()


    Dim dbs As DAO.Database
    Dim ctr As DAO.Container
    Dim i As Integer
    On Error GoTo ErrHandler
    Set dbs = CurrentDb
    Set ctr = dbs.Containers("Modules")
    For i = ctr.Documents.Count - 1 To 0 Step -1
    DoCmd.deleteobject acModule, ctr.Documents(i).Name
    Next i
    ExitHandler:
    On Error Resume Next
    Set ctr = Nothing
    dbs.Close
    Set dbs = Nothing
    Exit Function
    ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
    End Function

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Delete but one (Access 2000)

    For i = ctr.Documents.Count - 1 To 0 Step -1
    if ctr.Documents(i).Name <> "MdlBas"
    DoCmd.deleteobject acModule, ctr.Documents(i).Name
    end if
    Next i
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Star Lounger
    Join Date
    Sep 2002
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete but one (Access 2000)

    Thank you for the reply. Whys do i get a red colour when i write the folloiwng line in the function ?
    if ctr.Documents(i).Name <> "MdlBas"

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Delete but one (Access 2000)

    I forgot the "Then"

    if ctr.Documents(i).Name <> "MdlBas" Then
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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