"Method or data member not found" for a control on a UserForm
On an Excel, Word, or Outlook UserForm, VBA stops compiling at a line such as
UserForm1.List1.LinkChildFields = "OrderID" with the error Method or data member not found.
Other members of the same control compile, the Object Browser lists the member, and the same line
works in Access.
Environment
Microsoft 365 Office, Excel and Word (32-bit), UserForms (MSForms), on a computer where the WKL Forms Object Library was used on a UserForm before it was updated to a build with new members under the same type library version. Access forms aren't affected. Every release that changes the interface raises the type library version, so a correctly registered release doesn't show the symptom.
Cause
Office keeps a copy of a type library for each library ID and version, starting the first time one
of its controls is placed on a UserForm. Members added to the library later under the same version
remain unknown to the VBA compiler when it resolves UserForm1.List1.Member; a variable of the
control's own type still finds them, because it's bound through the reference. Deleting the
MSForms cache files (%TEMP%\VBE\*.exd) doesn't help. A new version number makes the members
visible right away. Access reads the type library again each time and never shows the symptom.
The product raises the version with every interface change, and registration removes other versions of the library. The symptom therefore appears only if an older build is still registered or a build was registered without raising its version.
Resolution
- Register the current release (How to: Install the released package). In the VBA editor, check (Tools › References) that the WKL Forms Object Library is listed with the version of the registered release; existing workbooks that reference an older version switch to it automatically.
- Close all Office applications and open the file again.
If the line must compile on a computer where the registration can't be updated, access the control through a variable of its own type; the code stays early-bound, with IntelliSense:
Dim myList As WklTreeList Set myList = UserForm1.List1 myList.LinkChildFields = "OrderID"