[AccessD] Events Collection??

Andy Lacey andy at minstersystems.co.uk
Tue Oct 19 17:00:00 CDT 2004


I've got code to look through module code but what I wanted was to find all
occurrences of a function call, some of which are calls fired direct from an
event without using an Event proc. So Michael's code did the job perfectly.
Thanks anyway Charlotte. And you're right, the code to find stuff in a
module is pretty horrible. Can't remember where I got it from. Works though.

-- Andy Lacey
http://www.minstersystems.co.uk 

> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com 
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of 
> Charlotte Foust
> Sent: 19 October 2004 22:00
> To: Access Developers discussion and problem solving
> Subject: RE: [AccessD] Events Collection??
> 
> 
> Only if you really *like* working with methods like ProcOfLine! ;-}
> 
> Here's some I wrote years ago to print a list of event 
> procedures in a form module to the immediate window.  It 
> tests for the existence of control event procedures in the 
> form and prints starting line of existing procedures or 
> MISSING for missing procedures.  Now THAT'S ugly!
> 
> Function TestEventProcs(ByVal strFrm As String)
>   On Error Resume Next
>   Dim frm As Form
>   Dim mdl As Module
>   Dim ctl As Control
>   Dim prp As dao.Property
>   Dim strSub As String
>   Dim lngSLine As Long
>   Dim lngSCol As Long
>   Dim lngELine As Long
>   Dim lngECol As Long
>   Dim intPfx As Integer
>   'make sure the form and its module are open
>   If Not IsLoaded(strFrm) Then
>     DoCmd.OpenForm strFrm, acDesign
>   End If
>   Set frm = Forms(strFrm)
>   Set mdl = Modules("Form_" & strFrm)
>   If Err <> 0 Then
>     DoCmd.OpenModule "Form_" & strFrm
>     Set mdl = Modules("Form_" & strFrm)
>   End If
>   'loop through the controls
>   'looking for event procedures
>   For Each ctl In frm.Controls
>     For Each prp In ctl.Properties
>       If prp.name Like "On*" Or _
>         prp.name Like "After*" Or _
>         prp.name Like "Before*" Then
>         'store the length of the prefix
>         If prp.name Like "On*" Then
>           intPfx = 2
>         ElseIf prp.name Like "After*" Then
>           intPfx = 5
>         ElseIf prp.name Like "Before*" Then
>           intPfx = 6
>         End If
>           
>         If prp.Value = "[Event Procedure]" Then
>           'initialize the line and colum variables
>           'for the proc find in the module
>           lngSLine = 0
>           lngSCol = 0
>           lngELine = 0
>           lngECol = 0
>           strSub = ctl.name & "_" & Mid(prp.name, intPfx + 1)
>           'look for the event procedure in the module
>           If mdl.Find(strSub, lngSLine, lngSCol, lngELine, 
> lngECol) Then
>             'if event procedure found,
>             'print its name and starting line
>             Debug.Print strSub & "() Exists"
>             Debug.Print , "Starts at line: " & lngSLine
>           Else
>             'otherwise, print name and MISSING
>             Debug.Print strSub & "() Is MISSING"
>           End If
>         End If
>       End If
>     Next prp
>   Next ctl
>   Set prp = Nothing
>   Set ctl = Nothing
>   Set mdl = Nothing
>   Set frm = Nothing
> End Function
> 
> Charlotte Foust
> 
> 
> -----Original Message-----
> From: Michael R Mattys [mailto:michael.mattys at adelphia.net] 
> Sent: Tuesday, October 19, 2004 12:58 PM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] Events Collection??
> 
> 
> > If you want to itemize the event procedures, you need to 
> work with the
> 
> > module, not the form itself.  It's very ugly code.
> > 
> > Charlotte Foust
> 
> 
> Ugly code? Should I defend myself? :)
> En Garde, Charlotte Foust!
> 
> ----
> 
> Michael R. Mattys
> Mattys MapLib for Microsoft MapPoint 
> http://www.mattysconsulting.com
> -- 
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com 
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> -- 
> _______________________________________________
> 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