Search code examples
ms-access-2010

Linking a sub form


I seem to have a strage problem regarding the linking of a sub form. I have a series of sub form linked to a master form in which upon loading all seem to work fine except one. On this particular one, I have linked the master field (control) to a control on the sub form. Very strangly, the link seems to be fine and when you toggle between the tabs where the sub forms are everything also seems to be fine. Unfortunately, after exiting the master form and then re-entering, the new data no longer appears.. (the data in the underlying table however is still there)

Also to note.. Strangely, when I remove all the links between the master form and the sub form upon viewing the form in view mode, no records are shown! (I was expecting to see ALL the records in the underlying table)

I would appreciate any advice.

Thanks, A


Solution

  • I have had a similar issue when linking multiple subforms to one master. One trick that I find quite useful is, instead of linking the subform using the forms field control, I do the following:

    1. Remove all links between the subform and the master form
    2. Open the subform in another window. In the data tab, select the table that it is linked to and, instead of the table, click the little '...' icon on the right to open in query window
    3. In the query editor select all the rows [editor: columns?] from the table, select the particular column that you want to link with the master, and in the criteria for that, define the path to the linked field in the master form. You can use the builder for that; it will be something like forms!frmMaster.controlname. Save and close the query and the form.
    4. On the Before Update event of the subform, you'll need to write a small procedure to auto update the linked field with the master form field as it won't do it automatically like it did when it was linked. Something like: Me.controlname.value = forms!frmMaster.controlname

    This should solve your problem