AllStoredProcedures Collection

Microsoft Access Visual Basic

Show All Show All

AllStoredProcedures Collection

Multiple objects AllStoredProcedures
AccessObject
AccessObjectProperties

The AllStoredProcedures collection contains an AccessObject for each stored procedure in the CurrentData or CodeData object.

Using the AllStoredProcedures Collection

The CurrentData or CodeData object has an AllStoredProcedures collection containing AccessObject objects that describe instances of all stored procedures specified by CurrentData or CodeData. For example, you can enumerate the AllStoredProcedures collection in Visual Basic to set or return the values of properties of individual AccessObject objects in the collection.

ShowTip

The For Each...Next statement is useful for enumerating a collection.

You can refer to an individual AccessObject object in the AllStoredProcedures collection either by referring to the object by name, or by referring to its index within the collection. If you want to refer to a specific object in the AllStoredProcedures collection, it's better to refer to the stored procedures by name because a stored procedure's collection index may change.

The AllStoredProcedures collection is indexed beginning with zero. If you refer to a stored procedure by its index, the first stored procedure is AllStoredProcedures(0), the second stored procedure is AllStoredProcedures(1), and so on.

Notes

  • The AllStoredProcedures collection only contains AccessObject objects within a Microsoft Access project (.adp). A Microsoft Access database (.mdb) does not contain any stored procedures, see the AllMacros collection.

  • To list all open stored procedures in the project, use the IsLoaded property of each AccessObject object in the AllStoredProcedures collection. You can then use the Name property of each individual AccessObject object to return the name of a stored procedure.

  • You can't add or delete an AccessObject object from the AllStoredProcedures collection.

The following example prints the name of each open AccessObject object in the AllProcedures collection.

Sub AllStoredProcedures()
    Dim obj As AccessObject, dbs As Object
    Set dbs = Application.CurrentData
    ' Search for open AccessObject objects in
    ' AllStoredProcedures collection.
    For Each obj In dbs.AllStoredProcedures
        If obj.IsLoaded = True Then
            ' Print name of obj.
            Debug.Print obj.Name
        End If
    Next obj
End Sub