which reference do I need to create objects"

Michael Burden 40 Reputation points
2025-08-20T20:28:03.92+00:00

I am having trouble creating object types in ACCESS VBA. I am using the statement:

Function BuildSQLInsertNewMold(objCurrMold As clsMold) As String

This produces the error User-type Not Defined when I try and compile the Function.

Is there a Reference I need to add in tools>references to be able to do this?

Microsoft 365 and Office | Access | For home | Windows
0 comments No comments
{count} votes

Answer accepted by question author
  1. HansV 462.1K Reputation points MVP Volunteer Moderator
    2025-08-20T20:52:13.6+00:00

    Presumably, clsMold refers to a Class Module of that name. If you do not have such a Class Module in your database, you'd get User Type Not Defined.

    Did you find the code somewhere? If so, see if it provides the code for a Class Module clsMold.

    2 people found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Michelle-N 6,685 Reputation points Microsoft External Staff Moderator
    2025-08-21T05:33:58.2666667+00:00

    Hi @Michael Burden

    Thank you for contacting us through the Microsoft Q&A forum.

    Based on your description, I understand you're getting a "User-defined type not defined" compile error in Access VBA when using clsMold as a data type in your function's arguments. After reproducing this error in my test environment, I have the following findings.

    In your Class Modules, you need to make sure the class's (Name) property is set precisely to clsMold. Consequently, all variable declarations using this object, like in your function, must also reference that exact name. As in the example from my test environment in the image below, please make the changes as shown in the bold blue text.User's imageUser's image

    This is just an example, so please be sure to change the data type name according to your own environment.

    If I've misunderstood you, please send me more details about what you want to do. I'll help you to the best of my ability


    If you found your answer helpful, click "Accept answer" to upvote it. If you have any other questions about this answer, please click "Comment".

    Note: If you want to receive email notifications related to this thread, follow the steps in the documentation to enable email notifications.Image preview

    2 people found 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.