Share via

Reference for DataObject

Doug 20 Reputation points
2026-05-19T13:27:53.73+00:00

Dim MyData As DataObject produces this error:

User's image

Is there a Reference to a dll required?

Microsoft 365 and Office | Access | Development
0 comments No comments

3 answers

Sort by: Most helpful
  1. Senthil kumar 395 Reputation points
    2026-05-19T15:00:34.4366667+00:00

    Hi Doug,

    • Import DLL from Tools-> Reference ->browse -> select FM20.DLL from C:\Windows\System32.

    User's image

    User's image

    Thanks

    Was this answer helpful?

    0 comments No comments

  2. Gabriel-N 17,530 Reputation points Microsoft External Staff Moderator
    2026-05-19T14:08:51.9933333+00:00

    Hello Doug

    From my experience, for DataObject, the required library is Microsoft Forms 2.0 Object Library (FM20.dll).

    Please press Alt + F11 to open the VBA editor, then go to Tools > References and scroll through the list until you find Microsoft Forms 2.0 Object Library. Check the box next to it and click OK.

    In case you cannot find it, you can click Browse..., then navigate to locations such as C:\Windows\System32\, C:\Windows\SysWOW64\, or other system folders, and look for a file named FM20.DLL. Select it and click Open.

    User's image

    Hope this information helps. If the issue persists, could you please upload your file to OneDrive and share it with me via private message so I can take a closer look?


    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


  3. AI answer

    2026-05-19T13:28:05.24+00:00

    Yes, a reference is required.

    In VBA, DataObject is not a built‑in type; it is defined in an external library. When Dim MyData As DataObject produces “User-defined type not defined”, it means the class is in a DLL/assembly that is not referenced by the project.

    To resolve this, add a reference to the library that defines DataObject (for example, the appropriate Office/InfoPath or other object library that exposes the DataObject interface). This aligns with the general rule that when a base class or type is defined in an external assembly, that assembly must be added as a reference so the compiler can find the type.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.