Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA code help needed

Status
Not open for further replies.

tani1978

MIS
Sep 29, 2005
49
DE
Hello Friends I have the following piece of code and I want to show the number of modules in the database. I tried it but it is not working.

Code:
Private Sub Command27_Click()

On Error GoTo Err_Command27
    Dim lngCounterA As Long, lngCounterB As Long, lngCounterC As Long
    Dim modModule As Module
    Dim zahl    
    Dim zahl1
    Dim zahl2
    
    
    
    For i = 0 To CodeDb.Containers("Modules").Documents.Count - 1
        RetVar = AllProcs(CodeDb.Containers("Modules").Documents(i).Name)
    Next i


    For lngCounterA = 0 To Modules.Count - 1
        Set modModule = Modules.Item(lngCounterA)
        zahl = 0
        With modModule
            For lngCounterB = 1 To .CountOfLines
                If Trim(.Lines(lngCounterB, 1)) = "EOF" Then
                   ' .ReplaceLine lngCounterB, "Washington"
                    zahl = zahl + 1
                End If
            Next lngCounterB
         '   Debug.Print "EOF kam im Modul " & modModule & "   " & zahl & " mal vor."
              zahl1 = 0
            For lngCounterC = 1 To .CountOfLines
                If Trim(.Lines(lngCounterC, 1)) = "Recordset" Then
                   ' .ReplaceLine lngCounterC, "Washington"
                    zahl1 = zahl1 + 1
                End If
            Next lngCounterC
        End With
        'Debug.Print "Recordset kam im Modul " & modModule & "   " & zahl1 & " mal vor."
        Me.Text28 = Me.Text28 & vbNewLine & "Recordset kam im Modul " & modModule & "   " & zahl1 & " mal vor."
    Next lngCounterA
    
Exit_Command27:
    Exit Sub
Err_Command27:
    MsgBox Err.Description, vbExclamation, "Error #" & Err.Number
    Resume Exit_Command27
End Sub
 
Here is the rest of code

Code:
Public Function AllProcs(strModuleName As String)
   
   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
   Dim lngR As Long
   
   Dim intBlankLineCount As Integer

   ' 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
   
   For intI = 0 To UBound(astrProcNames)

       Me.Text32 = Me.Text32 & vbNewLine & strModuleName & " - " & astrProcNames(intI)

       
       

   Next intI
   
End Function
 
Hi. It worked ok for me; i had to get rid of the ME references and just shoot it to the immediate window, but it worked. What problem are you having?

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top