Barvna shema: Temna
Trenutno dejavna stran: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » WKL Forms Object Library troubleshooting » An Access subform doesn't follow the grid

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 (KeyField with several fields). Value is 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

  1. 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).
  2. To link by a different field of the selected record, or with a composite key, use a second WklGrid as the detail instead of a subform. Its LinkMasterFields can name Grid1.CustomerID (How to: Link two grids without code).
  3. After you change the form in Design view, open it again in Form view.
  4. In code, Me!Sub1.Requery refreshes the subform at any time.
en/wiki/msaccess/comctl/troubleshooting/subform-does-not-follow-grid.txt · Zadnja sprememba: uporabnika Wolfgang van der Stille