• Subforms (Access 2002)

    Author
    Topic
    #429217

    I have two subforms (but plan to add more) displayed on one mainform; no record source has been identified on the main form. Both subforms are displayed in continuous format. I want one of the subforms to display all records; however based on the record that has focus the second subform should only display the records that match the first subform. I tried setting criteria in the query of the second form using [forms]![firstform]![fieldname]; but it does not recognize this field when I open the mainform.

    Viewing 0 reply threads
    Author
    Replies
    • #999038

      A subform is not part of the Forms collection, only main forms are. You must refer to a control on a subform by specifying the main form AND the subform, for example

      [Forms]![frmMain]![sbfFirst]![txtSomething]

      See Forms: Refer to Form and Subform properties and controls on the Access Web for a comprehensive overview.

      • #999055

        Do you have any examples using these Controls

        • #999061

          Many grin
          But what are you looking for in particular?

          • #999421

            Sorry; I thought that I had responded. I want to have one subform filter the values in another subform; when I click on the value a field in the first subform is in continuous format; I want the second subform to become visble and use the value in the first subform to filter the records displayed in the second subform in continuous format.

            • #999438

              Here is a very simple example. It uses stripped down versions of the Categories and Products tables from the Northwins sample database that comes with Access.
              The main form contains a subform based on the Categories table and a subform based on the Products table. Clicking in a category in the first one will display the associated products in the second one. The link is done through a hidden text box (its Visible property is set to No), no code is involved.

            • #1000118

              Thanks; this worked out fine; I took a look at it over the weekend and it works perfectly. Here my next question; can you changed the value of the subforms “Link child Fields” and the “Link Master Fields”; in the VBA Code based on if parameters?

            • #1000125

              Yes; the VBA names of the properties are LinkChildFields and LinkMasterFields (without spaces). Code looks like this:

              Me.SubFormName.LinkChildFields = “OrderID”

              (“Me” refers to the main form from which the code is run.)

            • #1024889

              Thanks all of this works great; I placed a command button on the subform to print the a report of subform values; however the report printed all the records from the table and not the records that where filter on the subform by using LinkChildFields and LinkMasterFields value.

            • #1024890

              You’ll have to tell the report in some way or other which records you want to print, it can’t smell that you want to print only those values displayed in the subform.

              We’ll need to know more details if you want more specific help.

    Viewing 0 reply threads
    Reply To: Subforms (Access 2002)

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

    Your information: