[AccessD] Iterating Controls

Arthur Fuller artful at rogers.com
Sun Mar 9 09:49:00 CST 2003


Swing and a miss! I thought you had a home run there but no. Here's the
whole sub, and all it prints is the names of the forms. Here's the entire
sub:

<code>

Public Sub ListRowSources()

    On Error Resume Next

    Dim frm As Object, db As CurrentProject, ctl As Control

    Dim strOutFile As String

    strOutFile = "RowSources.txt"        '"c:\testfile.txt"

    Set db = CurrentProject

    Dim fs As Object, a As Object

    Set fs = CreateObject("Scripting.FileSystemObject")

    Set a = fs.CreateTextFile(strOutFile, True)

 

    Set db = CurrentProject

 

    Application.Echo False

    

    Debug.Print "Analyzing Row Sources"

 

    'Walk through forms

    For Each frm In db.AllForms

        DoCmd.OpenForm frm.name, acDesign

        a.writeline "Form: " & frm.name

        'Walk through controls

        For Each ctl In frm.Controls

            With ctl

                Debug.Print ctl.Properties("Name")

                Select Case .ControlType

                    Case acComboBox

                        Debug.Print ctl.name & ": Combo Box"

                        Debug.Print ctl.RowSource

                        a.writeline "Control: " & ctl.name

                        a.writeline "RowSource"

                        a.writeline ctl.RowSource

                        

                    Case acListBox

                  Debug.Print ctl.name & ": List Box"

                        Debug.Print ctl.RowSource

                        a.writeline "Control: " & ctl.name

                        a.writeline "RowSource"

                        a.writeline ctl.RowSource

                Case Else

                  'do nothing

                End Select

            End With

        Next ctl

        DoCmd.Close acForm, frm.name

    Next frm

 

    Application.Echo True

    

    Set frm = Nothing

    Set db = Nothing

    Set fs = Nothing

    Set a = Nothing

 

 End Sub

</code?

 

All it does is print the form names. Not a single mention of any control on
any form. Clearly it's more wrong than On Error. But I'm not sure what.

Arthur

 

-----Original Message-----
From: accessd-admin at databaseadvisors.com
[mailto:accessd-admin at databaseadvisors.com] On Behalf Of Michael R Mattys
Sent: March 9, 2003 10:26 AM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] Iterating Controls

 

Hi Arthur,

 

You're looking too far to see it up close :)

On Error Resume Next

 

Mike Mattys

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030309/e6b2a8ed/attachment-0001.html>


More information about the AccessD mailing list