[AccessD] Delete all reports and all forms

Max Wanadoo max.wanadoo at gmail.com
Wed Mar 17 13:43:39 CDT 2010


Aha, very clever.  Lateral thinking again AD.

Much appreciated. I will run that later.

Cheers

Max
 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of A.D. Tejpal
Sent: Wednesday, March 17, 2010 6:34 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Delete all reports and all forms

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
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list