Results 1 to 4 of 4
  1. #1
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615

    Enumerate controls and their properties for all forms

    Hi All -



    How can I enumerate all controls on all the forms and reports in my database, without having to open them?

    This code:

    Code:
    Sub test()
      Dim frm As Form, ctl As Control, obj As Object
      For Each obj In CurrentProject.AllForms
        Debug.Print obj.Name
        For Each ctl In obj
        Next
      Next
      
    End Sub
    works fine to enumerate the forms/reports and their properties, e.g. the name, but when I try to get to the controls, the highlighted line generates the error 438, "Object doesn't support this property or method."

    I tried using frm instead of obj in the For each Obj line, but that resulted in a "Type Mismatch" error.

    I want to add the controls information to a database I have that lists all object references and cross references in an external (connected) database, for documentation (and cleanup of unused stuff).

    Thanks

  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,936
    allforms is not a collection of form objects which is why you are having a problem

    you can loop through allforms to find form names then to loop through each form for the controls, you have to open in design view

    see this link for an example

    https://bytes.com/topic/access/answe...ach-form-found

    Have you not considered using the documenter?

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    JohnG,

    I had a post a few years back that may be of some help. It creates a table with the info on each run.
    https://www.accessforums.net/access/...tml#post154208

    It's been a long time since I used it, but it helped a poster at the time.

    I'm sure I have referenced it with someone else, but can't find the post at the moment.

    Good luck.


    Update:
    JohnG -- I found the related post. This user was dealing with specific property, but the code could be adjusted.
    Last edited by orange; 01-28-2016 at 04:08 PM. Reason: found the related post -- properties

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    John,

    I wanted to do the same thing and started trying to document the form/report/control sources. It is still pretty rough, but you are welcome to use/modify/whatever....

    I want to be able to get the SQL in list/combo boxes. Don't think I am there yet - I was sidetracked and forgot where I left off.

    Import the objects into a dB, open the form and push the buttons.

    Hope it helps......
    Attached Files Attached Files

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 10-31-2015, 10:34 AM
  2. Replies: 1
    Last Post: 05-13-2013, 11:27 AM
  3. Forms Controls, Methods and Properties
    By cfwoodbury in forum Access
    Replies: 5
    Last Post: 10-09-2012, 09:35 AM
  4. Replies: 2
    Last Post: 08-28-2012, 03:43 PM
  5. Resizing Forms (Properties affecting behavior)
    By ajetrumpet in forum Tutorials
    Replies: 0
    Last Post: 07-17-2011, 04:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums