Get list of the controls on a closed form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    Get list of the controls on a closed form

    What is the code to create a list of the controls on a closed form in the
    current database?

    Thanks!

    Steve


  • Tom van Stiphout

    #2
    Re: Get list of the controls on a closed form

    On Sat, 11 Oct 2008 17:52:16 -0400, "Steve" <nonsense@nomse nse.com>
    wrote:

    There is no easy way to do that.

    -Tom.
    Microsoft Access MVP

    >What is the code to create a list of the controls on a closed form in the
    >current database?
    >
    >Thanks!
    >
    >Steve
    >

    Comment

    • Steve

      #3
      Re: Get list of the controls on a closed form

      Thanks for responding, Tom!

      What is the hard way?

      Steve


      "Tom van Stiphout" <tom7744.no.spa m@cox.netwrote in message
      news:ehd2f4dnmm f4jfsktl6nigja2 tejr8h3km@4ax.c om...
      On Sat, 11 Oct 2008 17:52:16 -0400, "Steve" <nonsense@nomse nse.com>
      wrote:
      >
      There is no easy way to do that.
      >
      -Tom.
      Microsoft Access MVP
      >
      >
      >>What is the code to create a list of the controls on a closed form in the
      >>current database?
      >>
      >>Thanks!
      >>
      >>Steve
      >>

      Comment

      • Tony Toews [MVP]

        #4
        Re: Get list of the controls on a closed form

        "Steve" <nonsense@nomse nse.comwrote:
        >Thanks for responding, Tom!
        >
        >What is the hard way?
        You open the form in design view. However that only works for MDBs. You can see
        Rick Fisher's Find and Replace work this way.

        Tony
        --
        Tony Toews, Microsoft Access MVP
        Please respond only in the newsgroups so that others can
        read the entire thread of messages.
        Microsoft Access Links, Hints, Tips & Accounting Systems at

        Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

        Comment

        • Steve

          #5
          Re: Get list of the controls on a closed form

          Thanks for responding, Tony!

          What is the code for getting the list of the controls once you have the form
          open in design view? You can't use:
          For each Ctl In Forms("MyForm") .Controls
          because the Forms collection doesn't exist when no forms are open.

          Further, If whatever you know works for MDBs, does it work for ACCDBs?

          Steve



          "Tony Toews [MVP]" <ttoews@teluspl anet.netwrote in message
          news:t3i2f4tbb9 07tf5jqhhg7luf9 i9qbanmh2@4ax.c om...
          "Steve" <nonsense@nomse nse.comwrote:
          >
          >>Thanks for responding, Tom!
          >>
          >>What is the hard way?
          >
          You open the form in design view. However that only works for MDBs. You
          can see
          Rick Fisher's Find and Replace work this way.
          >
          Tony
          --
          Tony Toews, Microsoft Access MVP
          Please respond only in the newsgroups so that others can
          read the entire thread of messages.
          Microsoft Access Links, Hints, Tips & Accounting Systems at

          Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

          Comment

          • Tom van Stiphout

            #6
            Re: Get list of the controls on a closed form

            On Sat, 11 Oct 2008 20:57:42 -0400, "Steve" <nonsense@nomse nse.com>
            wrote:

            Why would it NOT work in accdb? That's about database storage, not the
            forms package.

            Dim ctl As Control
            Dim strFormName As String

            strFormName = "_test1"
            DoCmd.OpenForm strFormName, acDesign
            For Each ctl In Forms(strFormNa me)
            Debug.Print ctl.Name
            Next
            DoCmd.Close acForm, strFormName

            -Tom.
            Microsoft Access MVP


            >Thanks for responding, Tony!
            >
            >What is the code for getting the list of the controls once you have the form
            >open in design view? You can't use:
            >For each Ctl In Forms("MyForm") .Controls
            >because the Forms collection doesn't exist when no forms are open.
            >
            >Further, If whatever you know works for MDBs, does it work for ACCDBs?
            >
            >Steve
            >
            >
            >
            >"Tony Toews [MVP]" <ttoews@teluspl anet.netwrote in message
            >news:t3i2f4tbb 907tf5jqhhg7luf 9i9qbanmh2@4ax. com...
            >"Steve" <nonsense@nomse nse.comwrote:
            >>
            >>>Thanks for responding, Tom!
            >>>
            >>>What is the hard way?
            >>
            >You open the form in design view. However that only works for MDBs. You
            >can see
            >Rick Fisher's Find and Replace work this way.
            >>
            >Tony
            >--
            >Tony Toews, Microsoft Access MVP
            > Please respond only in the newsgroups so that others can
            >read the entire thread of messages.
            > Microsoft Access Links, Hints, Tips & Accounting Systems at
            >http://www.granite.ab.ca/accsmstr.htm
            > Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
            >

            Comment

            • lyle fairfield

              #7
              Re: Get list of the controls on a closed form

              On Oct 11, 5:52 pm, "Steve" <nonse...@nomse nse.comwrote:
              What is the code to create a list of the controls on a closed form in the
              current database?
              >
              Thanks!
              >
              Steve
              Save the form as text. Parse the text file. Piece of cake. I'd do it
              if I could think of any use for it at all. But I can't.

              Comment

              • MikeB

                #8
                Re: Get list of the controls on a closed form

                On Oct 11, 4:52 pm, "Steve" <nonse...@nomse nse.comwrote:
                What is the code to create a list of the controls on a closed form in the
                current database?
                >
                Thanks!
                >
                Steve
                Not quite the answer you asked for but might this work?

                If you were to open the form from a program, but set it as hidden,
                then you would be able to get an object with a collection of all the
                controls. Once you have gotten from that what you want (made a list,
                whatever) you could close the form?

                Comment

                • John W. Vinson

                  #9
                  Re: Get list of the controls on a closed form

                  On Sat, 11 Oct 2008 17:52:16 -0400, "Steve" <nonsense@nomse nse.comwrote:
                  >What is the code to create a list of the controls on a closed form in the
                  >current database?
                  >
                  >Thanks!
                  >
                  >Steve
                  >
                  Depending on your version of Access, see the documentation on the AllForms
                  collection in VBA help.
                  --

                  John W. Vinson [MVP]

                  Comment

                  • Tony Toews [MVP]

                    #10
                    Re: Get list of the controls on a closed form

                    MikeB <MPBrede@gmail. comwrote:
                    >If you were to open the form from a program, but set it as hidden,
                    >then you would be able to get an object with a collection of all the
                    >controls. Once you have gotten from that what you want (made a list,
                    >whatever) you could close the form?
                    Trouble is some forms may have external dependencies such as a combo box query based
                    on another form. That will likely cause an error message to come up when the form
                    opens that you can't get around.

                    Thus open the form in design view.

                    Tony
                    --
                    Tony Toews, Microsoft Access MVP
                    Please respond only in the newsgroups so that others can
                    read the entire thread of messages.
                    Microsoft Access Links, Hints, Tips & Accounting Systems at

                    Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

                    Comment

                    • Rick Brandt

                      #11
                      Re: Get list of the controls on a closed form

                      Steve wrote:
                      Thanks for responding, Tony!
                      >
                      What is the code for getting the list of the controls once you have
                      the form open in design view? You can't use:
                      For each Ctl In Forms("MyForm") .Controls
                      because the Forms collection doesn't exist when no forms are open.
                      A form opened in design view is open and therefore IS in the Forms
                      collection.
                      Further, If whatever you know works for MDBs, does it work for ACCDBs?
                      He didn't mean "works in MDB, not in AccDB". He meant "works in MDB, not
                      MDE". In this case AccDB = MDB and AccDE = MDE.

                      --
                      Rick Brandt, Microsoft Access MVP
                      Email (as appropriate) to...
                      RBrandt at Hunter dot com



                      Comment

                      • Tony Toews [MVP]

                        #12
                        Re: Get list of the controls on a closed form

                        "Tony Toews [MVP]" <ttoews@teluspl anet.netwrote:
                        >You open the form in design view. However that only works for MDBs.
                        And ACCDBs. I'm going to have to be more careful in this respect in the future.
                        <smile You can't open a form or report in design view in MDE or ACCDEs.

                        Tony
                        --
                        Tony Toews, Microsoft Access MVP
                        Please respond only in the newsgroups so that others can
                        read the entire thread of messages.
                        Microsoft Access Links, Hints, Tips & Accounting Systems at

                        Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

                        Comment

                        • David W. Fenton

                          #13
                          Re: Get list of the controls on a closed form

                          "Tony Toews [MVP]" <ttoews@teluspl anet.netwrote in
                          news:t3i2f4tbb9 07tf5jqhhg7luf9 i9qbanmh2@4ax.c om:
                          "Steve" <nonsense@nomse nse.comwrote:
                          >
                          >>Thanks for responding, Tom!
                          >>
                          >>What is the hard way?
                          >
                          You open the form in design view.
                          Uh, why not just open the form in regular view? Why does it have to
                          be in design view? And I didn't know that the Controls collection
                          existed in a form open in design view.

                          --
                          David W. Fenton http://www.dfenton.com/
                          usenet at dfenton dot com http://www.dfenton.com/DFA/

                          Comment

                          • Tony Toews [MVP]

                            #14
                            Re: Get list of the controls on a closed form

                            "David W. Fenton" <XXXusenet@dfen ton.com.invalid wrote:
                            >Thinking through this, I wonder if anyone has a position on whether
                            >opening the form in data entry mode might not be just as easy as
                            >design mode? What advantage would there be in using design view? No
                            >locking?
                            A lot of this depends on why he is wants the control list. My assumption is that he
                            needs it for some of his own development requirements whatever they might be.
                            Therefore opening it in Edit mode saves some errors that might occur if the form was
                            opened in regular mode.

                            Tony
                            --
                            Tony Toews, Microsoft Access MVP
                            Please respond only in the newsgroups so that others can
                            read the entire thread of messages.
                            Microsoft Access Links, Hints, Tips & Accounting Systems at

                            Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/

                            Comment

                            • Marshall Barton

                              #15
                              Re: Get list of the controls on a closed form

                              John W. Vinson wrote:
                              >On Sat, 11 Oct 2008 17:52:16 -0400, "Steve" <nonsense@nomse nse.comwrote:
                              >
                              >>What is the code to create a list of the controls on a closed form in the
                              >>current database?
                              >>
                              >>Thanks!
                              >>
                              >>Steve
                              >>
                              >
                              >Depending on your version of Access, see the documentation on the AllForms
                              >collection in VBA help.

                              But an AccessObject does not have a Controls collection.
                              For this purpose AllForms is no more useful than
                              Containers!Form s.Documents.

                              --
                              Marsh

                              Comment

                              Working...