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!

Showing results in the same Form

Status
Not open for further replies.

tani1978

MIS
Sep 29, 2005
49
DE
Hello Friends,
I have a form with the following code to list the modules in the immediate window. I want that the results shown in immdiate windows should appear on the same form.How should i change my code?

[/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 ' das ist Dein Zähler
Dim zahl1
Dim zahl2

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."

Next lngCounterA

Exit_Command27:
Exit Sub
Err_Command27:
MsgBox Err.Description, vbExclamation, "Error #" & Err.Number
Resume Exit_Command27
End Sub


Code:
 
Put an unbound textbox (txt1) on the form:
Then use:

me.txt1= me.txt1 & vbnewline & "Recordset kam im Modul " & modModule & " " & zahl1 & " mal vor.
 
Thanks for your answer it worked but there is another problem now in the other Module, which is not letting the same scenario happen. Sorry but my VBA capabilities are not good.

Code:
Private Sub ListModules_Click()

On Error Resume Next
    Dim obj As Object
    Dim i As Integer
    Dim j As Long
    Dim RetVar As Variant
    
    'For Each obj In CurrentProject.allforms
    '   DoCmd.OpenForm obj.Name, acDesign
    '   If Forms(obj.Name).HasModule = True Then
    '       AllProcs ("Form_" & obj.Name)
    '   End If
    'Next
    
    'For Each obj In CurrentProject.AllReports
    '   DoCmd.OpenReport obj.Name, acDesign
    '   If Reports(obj.Name).HasModule = True Then
    '       AllProcs ("Report_" & obj.Name)
    '   End If
    'Next
    
    For i = 0 To CodeDb.Containers("Modules").Documents.Count - 1
        RetVar = AllProcs(CodeDb.Containers("Modules").Documents(i).Name)
    Next i

End Sub
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.Text30 = Me.Text30 & vbNewLine & "strModuleName & " - " & astrProcNames(intI)"
   Next intI
   
End Function

but with this line the result is shown in immediate window.

Code:
Debug.Print strModuleName & " - " & astrProcNames(intI)
 
Any time you have a debug.print you are sending a string to your immediate window. If you want to show this on the form, add another Textbox control, and change

Debug.Print

to

Me.YourTextBoxName =

HTH
 
Me.Text30 = Me.Text30 & vbNewLine & strModuleName & " - " & astrProcNames(intI)
 
well thanks for all of your suggestions it worked the way I want but somehow at the end I was standing with empty hands because the code written above works well in mdb file but when i make a mda file and add it as an add-in then this does not work. In the mdb file the result was shown in the unbound item but also in the immediate window keeping in mind i have removed all the debug.print instructions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top