Results 1 to 2 of 2
Thread: delete all modules (Access 2000)
2005-04-28, 15:02 #1
- Join Date
- Jul 2001
- Thanked 0 Times in 0 Posts
delete all modules (Access 2000)
Is there a function deleting all modules? I am deleting the modules one by one with:
DoCmd.DeleteObject acModule, "Module1"
I am interested to knwo can i delete all the modules present without enumerating them?
2005-04-28, 15:19 #2
- Join Date
- Mar 2002
- Thanked 30 Times in 30 Posts
Re: delete all modules (Access 2000)
If you delete ALL modules you will also delete the module that contains the code to delete all modules! <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>
The following procedure will delete all modules. Replace basThisOne with the name of the module that contains the DeleteModules code. If you don't want to delete the module that contains DeleteModules, comment out the line above End Sub.
Dim i As Long
Dim n As Long
n = CurrentProject.AllModules.Count
For i = n - 1 To 0 Step -1
If Not CurrentProject.AllModules(i).Name = "basThisOne" Then
DoCmd.DeleteObject acModule, CurrentProject.AllModules(i).Name
' This line will delete the module that contains the code
DoCmd.DeleteObject acModule, "basThisOne"