Tips Forum Logo
Tips Forum Home PageSpacerVisit Microsoft Knowledge BaseMAUG Home PageMAUG Russian Home Page

Функция, выдающая список всех процедур в модуле
A function that lists names of all procedures from given module

Applies to: Access 97

Function ListAllProcs(strModuleName As String)
'Purpose: lists all procedures/functions for given module
'Example: call allprocs("Utils_7Dec99")
Dim mdl As Module
Dim lngCount As Long, lngCountDecl As Long, lngI As Long
Dim strProcName As String, astrProcNames() As String
Dim intI As Integer, strMsg As String
Dim lngR As Long

' Open specified Module object.
DoCmd.OpenModule strModuleName
' Return reference to Module object.
Set mdl = Modules(strModuleName)
' Count lines in module.
lngCount = mdl.CountOfLines
' Count lines in Declaration section in module.

lngCountDecl = mdl.CountOfDeclarationLines
' Determine name of first procedure.
strProcName = mdl.ProcOfLine(lngCountDecl + 1, lngR)
' Initialize counter variable.
intI = 0
' Redimension array.
ReDim Preserve astrProcNames(intI)
' Store name of first procedure in array.
astrProcNames(intI) = strProcName

' Determine procedure name for each line after declarations.
For lngI = lngCountDecl + 1 To lngCount
' Compare procedure name with ProcOfLine property value.

If strProcName <> mdl.ProcOfLine(lngI, lngR) Then
' Increment counter.
intI = intI + 1
strProcName = mdl.ProcOfLine(lngI, lngR)
ReDim Preserve astrProcNames(intI)
' Assign unique procedure names to array.
astrProcNames(intI) = strProcName
End If
Next lngI

strMsg = "Procedures in module '" & strModuleName & "': " _
& vbCrLf & vbCrLf
Debug.Print "Procedures in module '" & strModuleName & "': "

For intI = 0 To UBound(astrProcNames)
strMsg = strMsg & astrProcNames(intI) & vbCrLf
'Print list in debug window:
Debug.Print astrProcNames(intI)
Next intI

' Dialog box listing all procedures in module.
MsgBox strMsg
End Function

From  Dejan Mladenovic , Entry Date 24.11.1999

Microsoft Access Solutions

Written and designed by
Alex Dybenko
Send us your comments
Last Update: 2007-10-15
Copyright © 1998-2007 by MAUG

Alex & Access