An Access subform doesn't follow the grid
The subform on the form shows no records, or only the records for the first master record, even
though its Link Master Fields property names a WklGrid (or another WKL control) on the form
and the user selects other records in it.
Environment
WKL Forms Object Library 1.15 and later; Access in Microsoft 365; ACCDB, ACCDE, and the Access Runtime.
Cause
Access reads the linked control's value through its Value property (for a WKL control, the
selected key), but it doesn't refresh a subform when that value changes; neither a change
notification from the control nor anything else makes it do so. That's why the grid requeries
the subforms on its form whose Link Master Fields name it each time its selected record
changes. This fails when:
- Link Master Fields contains something other than the control's name, such as
Grid1.CustomerID, a field on the form, or the name with a typo. Only the plain name is recognized. - The grid has a composite key (
KeyFieldwith several fields).Valueis then an array, which Access can't compare with a field in the subform. - The subform control was added or renamed while the form was open in Form view. The grid looks for linked subforms only once, when it opens.
Resolution
- Set the subform's Link Master Fields to the grid's name only (
Grid1) and Link Child Fields to the field that holds the grid's key (CustomerID). - To link by a different field of the selected record, or with a composite key, use a second
WklGridas the detail instead of a subform. ItsLinkMasterFieldscan nameGrid1.CustomerID(How to: Link two grids without code). - After you change the form in Design view, open it again in Form view.
- In code,
Me!Sub1.Requeryrefreshes the subform at any time.
en/wiki/msaccess/comctl/troubleshooting/subform-does-not-follow-grid.txt · Zadnja sprememba: uporabnika Wolfgang van der Stille