• Forms Collection issue! (Access 2000 SP2)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Forms Collection issue! (Access 2000 SP2)

    Author
    Topic
    #376339

    This is DRIVING me nuts! For some reason, last few months, I can’t figure this out. Whenever I try to use a Forms collection (Forms!frmxxx!xxx), I keep on getting an error message saying that it cannot find the form! I checked everything, the names is right, etc. Even if I follow examples from others, it still doesn’t work. Please help. ranton

    Viewing 0 reply threads
    Author
    Replies
    • #615953

      Are the forms your looking for Open? They need to be open for the Collection to show them.

      HTH
      Paul

      • #615957

        That was the oddest thing. I knew that subform has to be open for this to work. When I open the main form, I see the whole thing (Main form and subforms), so I assume it is “open”? Or is it defined differently? Can a subform that I can see on the main form be considered “closed”?

        Brent

        • #615959

          A subform is NOT in the forms collection! Is is not considered an open form. To access a subform, you must reference it via the subform control name on the mainform (which may or may not be the same as the subform’s name). Something like this:
          Forms!MainformName!subformControlname.Form!someControlName

          • #616060

            I am not too sure what you mean by subformControlname.Form?

            Should I type: forms!frmA!fsubA!cboName

            OR

            forms!frmA!cboName.fsubA ?

            Thanks.

            • #616073

              Let’s use some examples. Let’s say you have 2 forms in your database window: frmCustomers and frmPhones. Form frmPhones contains a textbox named txtPhoneNo. If you look on frmCustomers, you will see a subform control. That control has a Name property (which may be something like “subPhones”) and a SourceObject property (which is the name of the actual form it contains, frmPhones). If you want to reference the Phone# on the current row in the subform, the complete syntax would be:
              Forms!frmCustomers!subPhones.Form!txtPhoneNo

              Which essentially says “Look in the Forms collection, find form frmCustomers, and on it find the control subPhones, then look at the Form it contains and find control txtPhoneNo”.

            • #616162

              In the latest versions of Access you can shortcut the reference by leaving out the “.form” part between the subform controlname and the control on the subform, giving you this:

              Forms!frmCustomers!subPhonestxtPhoneNo

              I believe in 97 you had to include it, but not in 2000 or later.

            • #616235

              Yeah, I know that .Form is the default property for the subform control, and that I really don’t have to use. However, I use still use it myself because I find it makes the code easier to read, and I use it when explaining the concept to other people because I think it helps them understand the relationship of the form within the subform control.

            • #616450

              I really pointed it out because in A97, you *do* have to use it.

    Viewing 0 reply threads
    Reply To: Forms Collection issue! (Access 2000 SP2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: