A.D. Tejpal
adtp at airtelmail.in
Wed Mar 17 13:34:09 CDT 2010
Max,
It can be done quite conveniently in DAO. For smooth deletion of all forms/reports, you have to do the deletion part outside the For Each loop.
Sample procedure named P_DeleteAllForms() as given below, will remove all forms in the db. Just make sure that all forms are in closed state before running the subroutine.
Similar procedure can be devised for deleting all reports.
Best wishes,
A.D. Tejpal
------------
' Sample procedure for deleting all forms.
'===========================
Sub P_DeleteAllForms()
' Before running this subroutine,
' pl. make sure that no form is in open state
Dim obj As Object
Dim Rtv As Variant, Cnt As Long
ReDim Rtv(CurrentProject.AllForms.Count - 1)
Cnt = 0
For Each obj In CurrentProject.AllForms
Rtv(Cnt) = obj.Name
Cnt = Cnt + 1
Next
For Cnt = 0 To UBound(Rtv)
DoCmd.DeleteObject acForm, Rtv(Cnt)
Next
Set obj = Nothing
End Sub
'===============================
----- Original Message -----
From: Max Wanadoo
To: 'Access Developers discussion and problem solving'
Sent: Wednesday, March 17, 2010 21:58
Subject: [AccessD] Delete all reports and all forms
Anybody know how to loop through and delete all reports and all forms.
It seems that Access will not let you delete from the collections.
Must be a programmable way but never done it before.
Max