• Subform Will Not Update Itself When Control Source

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Subform Will Not Update Itself When Control Source

    Author
    Topic
    #353381

    Subform Will Not Update Itself When Control Source is Changed Programically

    When I change a subform’s Control Source i cannot get the subform to update itself with information according to its Link Child Fields and Link Master Fields.

    My application is a contact manager. Here’s a schematic of what i have done:

    Contact ID (continuous form)
    |
    |
    Detail Subform (single form)—–(cmd buttons) Adresses | Phone Numbers

    Explanation, the ContactID is used to sync up the Detail subform to show only a specific contact’s info. The cmd buttons will change the Control Source of the Detail subform so that different forms will be displayed.

    This is how i am syncing the ContactID continuous form with the Detail subform: I use an unbound textbox that gets updated by the ContactID continuous form; the unbound textbox is then the Link Master Field for the Detail subform.

    Does anybody have suggestions how I might get this changing subform to update itself? I have tried programically re-defining the Link Child Fields and Link Master Fields after changing the Control Source, as well as to Refresh and Requery the changed subform- no deal.

    Thank you!
    –llyal

    Viewing 0 reply threads
    Author
    Replies
    • #516817

      llyal,

      You can’t have a subform on a continuous form, so I suspect that terminology may be part of the problem.

      Is your “contactID” form, which you indicated is continuous, actually a subform itself? That would mean that either you have two subforms on the parent form, or that your “Detail Subform” is actually a popup form and is independent of the ContactID form, or that the “Detail Subform” is actually the parent form. Or could it be that ContactID is a combobox control rather than a form at all?

      What is the name of the form that contains and is linked to the Detail Subform?

      • #516889

        Sorry for the confusion. The two forms are subforms on a unbound main form; the ContactID subform is a continuous form, the Detail subform is a single form; the ContactID subform controls the Detail subform.

        The two test forms I am using with the Details subform (by changing SourceObject) are frmDetailsSubPrimaryMain and frmDetailsSubSecondaryMain.

        When I first open the main form, the frmDetailsSubPrimaryMain is the default form in the Details subform. It will update itself fine from the ContactID subform. When I programically change the Detail subform default form to frmDetailsSubSecondaryMain, I find that it will display the data of the first record in the ContactID subform and will not update itself, as I move through the ContactIDs. I have tried re-defining the Master, Child links, requery, and refresh, with no success.

        In summary, changing the Detail subform Source Object does not give expected results.

        I realize these descriptions are confusing, but i do not know how to simplify it at this time.

        Thank you!

        –llyal

        • #517024

          OK, you have two subforms on an unbound parent form, right? You want to use an unbound control to link the subforms to the parent, and this is actually possible. It seems to work with the default subform but not with the alternative according to your description. Does it work if you set the sourceobject back to the default subform?

          I would suspect either something in the code that sets the SourceObject to the other subform is not doing what you intend or you need a requery in there somewhere. If you post the code, someone may spot the problem.

          As an aside, had you thought about making the parent form bound? I often do this, even though I don’t use any bound controls on the parent form. I bind the parent form to a recordset that returns nothing but the linkfields I need for any bound subforms. Then I use an unbound combobox to select the record I need and use bookmark navigation to move the recordset to that record. The links keep the subforms in sync automatically, even if I change the sourceobject along the way.

          • #517090

            I am doing all that you suggested, the problem is the changing the control source and then having that new form sync up with data like the form it replaced did.

            I realize that this problem is hard to simplify for a help forum.

            Let me ask- changing the control source (meaning changing the form) of a subform control should be straight-forward, in respects to the form syncing its data? This answer to help me focus what I need to concentrate on as a problem.

            Thanks!

            –llyal

    Viewing 0 reply threads
    Reply To: Subform Will Not Update Itself When Control Source

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

    Your information: