Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping through all forms and deleting them

Status
Not open for further replies.

zevw

MIS
Jul 3, 2001
697
US
I am looping through a Database and want to delete all its Forms, in the middle of looping it gives me a error the object or Name does not exist or invalid.

Is there a more proper way how to do this?

Code:
Dim frmName As String, i As Integer

    For i = 0 To CurrentProject.AllForms.Count - 1
      frmName = CurrentProject.AllForms(i).Name
      [COLOR=#73D216]'On Error Resume Next[/color]
      DoCmd.DeleteObject acForm, frmName
    Next I
 
Replace this:
For i = 0 To CurrentProject.AllForms.Count - 1
with this:
For i = CurrentProject.AllForms.Count - 1 To 0 Step -1

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top