The control shows error text instead of nodes
In Form view, the control shows a message instead of nodes, for example, that a field is missing, that a key occurs twice, or that Access reported an error while reading the data.
Environment
All versions of WklTreeView and WklTreeList.
Cause
When the control loads on its own (because the form opens or a property changed), it shows a load
error as text in the control instead of interrupting the user. When the load is triggered from VBA
(Requery, SelectedKey = …, NodeCount), the same error raises a VBA error with a fixed number:
| Constant | Cause |
|---|---|
wkeNotConfigured | RecordSource, KeyField, ParentField (or GroupFields) or TextField is empty |
wkeSourceError | Access couldn't read the source: unknown table or field, SQL syntax error, missing parameter, or broken link; the Access message follows |
wkeDuplicateKey | Two records have the same value in KeyField |
wkeCycle | The parent keys form a cycle (A is the parent of B, and B is the parent of A) |
Resolution
- Read the message; for
wkeSourceError, it contains the original Access message. - Open the record source in Datasheet view: it must open without prompts and contain the fields named in
KeyField,ParentField, andTextField. - Make
KeyFieldunique (a primary key), and check the parent keys for cycles. - Queries with parameters: parameters are resolved like form references (
Forms!frmMain!txtYear), so the referenced form must be open.
en/wiki/msaccess/comctl/troubleshooting/control-shows-error-text.txt · Last modified: by Wolfgang van der Stille