VBA Compile Error - Probably Simple (1 Viewer)

Shisho2k

Registered User.
Local time
Today, 05:50
Joined
Aug 12, 2012
Messages
29
I'm getting the "User defined type not defined" error when I try to compile my VBA code in debug. The issue here though is that it doesn't point to anything. -_-

I think I've narrowed it down to a class module I created, but I can't think of why this would throw this complaint. The code executes and the class methods and properties work fine. There aren't any special or custom data types I used in the class itself. So possibly referencing my class is what it thinks is undefined. Does the initialize() sub have to be public or something odd like that?

I'm also fairly confident that none of my references are missing. I've deleted forms/reports/code modules one by one, and it seems the ones using my new class that are causing it. Though it won't point to it directly in the debugging.

I feel like I'm over looking something, but I couldn't find any ideas related to this error message that have worked so far.

Any suggestions?
 

vbaInet

AWF VIP
Local time
Today, 10:50
Joined
Jan 22, 2010
Messages
26,374
What kind of objecst are you creating in your class? You must be missing a reference to one or more of their libraries.
 

Shisho2k

Registered User.
Local time
Today, 05:50
Joined
Aug 12, 2012
Messages
29
The only outside objects I've used are Collections.

The rest of the stuff is strings, integers, longs, etc. The standard stuff. Do you think I need some reference to the Collection class?
 

vbaInet

AWF VIP
Local time
Today, 10:50
Joined
Jan 22, 2010
Messages
26,374
Yes you do. I'm sure you had it there before using it. From memory I think the reference is called Microsoft Scripting Runtime.
 

Shisho2k

Registered User.
Local time
Today, 05:50
Joined
Aug 12, 2012
Messages
29
It wasn't added. I just added it, but it continues with the same message. I'll dig through again and see if there aren't any other unreferenced objects.
 

Shisho2k

Registered User.
Local time
Today, 05:50
Joined
Aug 12, 2012
Messages
29
Aside from Collection and the three I made DataField, DataInterface, DataRecord

Which just hold various pieces of information about records and performs methods on them. All the code works, just the not compiling now.

Searching through all the project for "= new" doesn't return anything than those three.

I used some 3rd party code module for some text width/height code, but with or without I still get the error. It declares various functions used in "kernal32" "user32" and "gdi32", but again, it doesn't seem to be having reference issues there, as I still have the problem if I remove this module and comment out the handful of calls to it's getWidth function.
 

Shisho2k

Registered User.
Local time
Today, 05:50
Joined
Aug 12, 2012
Messages
29
Might it be an issue with RecordSet or what CurrentDB returns?
 

vbaInet

AWF VIP
Local time
Today, 10:50
Joined
Jan 22, 2010
Messages
26,374
Can you upload a version of your db? I don't need any confidential information, just the relevant bits.
 

Shisho2k

Registered User.
Local time
Today, 05:50
Joined
Aug 12, 2012
Messages
29
Sure I'll message it to you in a minute. It's just something I'm working for just keeping track of some stuff. I'd rather have it digital than write in a notebook. X)
 

Shisho2k

Registered User.
Local time
Today, 05:50
Joined
Aug 12, 2012
Messages
29
Sent you a ZShare link, hopefully that works. ;)

Thanks for taking a look.
 

vbaInet

AWF VIP
Local time
Today, 10:50
Joined
Jan 22, 2010
Messages
26,374
What steps should I take to reproduce the error? I thought you said it doesn't compile. Since that's not the case, there's a function being called somewhere that doesn't exist.
 

Shisho2k

Registered User.
Local time
Today, 05:50
Joined
Aug 12, 2012
Messages
29
That's strange, the compile error I'm getting is when I go to the VB editor and Debug > Compile (Project Name) in the menu.

That's when it tells me I have an undefined type.

Do you know which function?
 

vbaInet

AWF VIP
Local time
Today, 10:50
Joined
Jan 22, 2010
Messages
26,374
Your project compiled here. Unless you didn't try compiling on the version you uploaded.
 

Shisho2k

Registered User.
Local time
Today, 05:50
Joined
Aug 12, 2012
Messages
29
Wait a second, do you have to close and reopen the project for it to recognize when you add a new reference, or something to that effect?

It's compiling now. I think the collection reference you told me to add is what it was. Because now that I reopened it from when I sent it to you, it is compiling. >_<
 

vbaInet

AWF VIP
Local time
Today, 10:50
Joined
Jan 22, 2010
Messages
26,374
Not necessarily. You just need to add the reference and compile. Sometimes it helps to close and reopen it.
 

Shisho2k

Registered User.
Local time
Today, 05:50
Joined
Aug 12, 2012
Messages
29
Yeah it's acting strange again if I remove it. I readded it, and opened and closed, but I guess it isn't recognizing it still and the error is still happening.

Maybe I have to fiddle around with loaded and closing stuff to get it whatever it is to see the reference. Weird. :banghead:
 

Shisho2k

Registered User.
Local time
Today, 05:50
Joined
Aug 12, 2012
Messages
29
Thanks so much. ^_^

Going to give that resource a look.
 

vbaInet

AWF VIP
Local time
Today, 10:50
Joined
Jan 22, 2010
Messages
26,374
Then compile afterwards. By the way, the db you sent didn't have a reference to the Scripting Runtime but I can see that you have code that uses a Collection, I compiled it and it didn't error. Something buggy there.
 

Users who are viewing this thread

Top Bottom