Solved FAYT User type undefined (1 Viewer)

ClaraBarton

Registered User.
Local time
Today, 01:21
Joined
Oct 14, 2019
Messages
479
I use Majp FAYT in nearly all my databases. Never a problem. (or at least not THIS problem). Suddenly my code won't compile because this is a user-defined type not defined:
Code:
Public faytCategory As New FindAsYouTypeCombo
Right after Option Explicit
I've check all my references and they are the same as in the other databases.
I've put all objects into a new database. Same problem.
I have two forms with FAYT neither will compile.
Surely I'm missing something very obvious here.
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:21
Joined
Sep 21, 2011
Messages
14,366
His class code modules?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:21
Joined
Sep 12, 2006
Messages
15,662
Is there an ordering thing? Does the findasyoutypecombo unit/module need to be sorted/declared above the current unit/module
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:21
Joined
Sep 21, 2011
Messages
14,366
Not that I am aware off. I seem to recall you just copy the modules into your dB and then use them. Been a while since I needed to do it.

Here are mine from my Diabetes DB
1714160906628.png

In the form
Code:
Option Compare Database
Option Explicit
Public faytFood As New FindAsYouTypeCombo

In the load
Code:
Private Sub Form_Load()
    ' Initialise FAYT combo
    faytFood.InitalizeFilterCombo Me.cboFoodIDFK, "FoodName", anywhereinstring, True

End Sub

That is pretty much all you do/need.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 04:21
Joined
May 21, 2018
Messages
8,555
Unclear, but I assume you do have the class module in the project. If so then my first guess is there is a broken reference to something else. References are compiled in alphabetical order, and if there is a broken reference before it, it can hang on an unrelated referenced method or procedure.
 

ClaraBarton

Registered User.
Local time
Today, 01:21
Joined
Oct 14, 2019
Messages
479
Yes, the class module is there. I also assumed the problem was the references but I'm unclear what to do about them. What references would the FAYT module require? If there was a problem with them, wouldn't there be problems in other databases? I'll try to figure out how to refresh them.
1714178699736.png
 
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 04:21
Joined
May 21, 2018
Messages
8,555
What references would the FAYT module require?
Does not seem to be the problem. Can you post a problem DB?

It would not require a reference, but a broken reference can cause cascading problems. In your image the references are compiled in the listed priority order. See the up and down arrows? That is so you can modify the order.
If say your reference for "OLE Automation" was broken the compiler cannot get to the ones below it. So anything using office 16.0 or access 16.0 would likely fail.

The most common problem you see is when you try to use a string function (left, right, instr, len, etc.) and all of a sudden it says it cannot find that function which you have used a million times. These functions are in the VBA library at the top of your list. But if you have a broken reference before that then these never compile.

Another similar problem is when you have a reference to ADODB and DAO. (used to be a big problem where you have two seperate references)
If you declared something like

dim rs as recordset
set rs = me.recordset

if in your list you had the reference to ADODB first the above code fails. Because the compiler comes to that reference first.
If you list the reference to DAO first then the above code works.

In the first case it assumes you mean
dim rs as adodb.recordset

So broken references and even the order of references can have cascading effects.
 

ClaraBarton

Registered User.
Local time
Today, 01:21
Joined
Oct 14, 2019
Messages
479
There is a FAYT combo on frmRegister and frmsubCategory. Thank you for looking at it.
 

Attachments

  • ToSend.accdb
    5.1 MB · Views: 15

Gasman

Enthusiastic Amateur
Local time
Today, 09:21
Joined
Sep 21, 2011
Messages
14,366
1714234247927.png
?????

Compare your pic to mine?
I renamed it to the correct name and the form opens fine?
1714234428344.png
 

ClaraBarton

Registered User.
Local time
Today, 01:21
Joined
Oct 14, 2019
Messages
479
You make me feel very stupid... but I'm not seeing what you're saying: What is the correct name?
1714236236340.png
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:21
Joined
Sep 21, 2011
Messages
14,366
Look at the name in your initial post.
 

ClaraBarton

Registered User.
Local time
Today, 01:21
Joined
Oct 14, 2019
Messages
479
So... to be clear here... class modules need the exact name but modules should not have the name of their subs?
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:21
Joined
Sep 21, 2011
Messages
14,366
I am not an expert on classes, I just use @MajP 's classes ;)

However each one appears to be like an object, everything is encaspulated in that class, so the name must be the same.
With standard modules, they hold many functions and subs, and even then their name has to be different.

The class holds all the methods that it will use, the modules do not, they just hold unrelated code.

That is the best I can explain it, as I understand it. :(
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:21
Joined
Sep 12, 2006
Messages
15,662
So... to be clear here... class modules need the exact name but modules should not have the name of their subs?
With a module you call a procedure inside the module, so the module just can't be named the same as one of its procedures.

With a class module, the whole thing is a complete unit, and you instantiate an object of that type. The procedures and functions within the class module are methods of the class.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 04:21
Joined
May 21, 2018
Messages
8,555
@ClaraBarton
You can rename the classes if you want, you just have to declare them with the new name. You will know this because intellisense will tell you if the class exists.
In your case you should have known because when you typed

Public faytFood as New find..... (nothing would come up in intellisense telling you there is a problem)

If you named the find as you type combo to just FAYTcombo then you now have a class FAYTcombo
Code:
Public faytFood As New FAYTcombo
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 04:21
Joined
May 21, 2018
Messages
8,555
class modules need the exact name but modules should not have the name of their subs?
Class modules can have any name and you can change it. But when you declare an object of that class it has to be the name you are using in the project
private myObj as myClassName

Both standard modules and class modules cannot have methods by the same name as the module. If you have a standard module named "MyFunction" you cannot have a method in the module called "MyFunction"

Things inside the class are completely protected so there are no naming conflicts with other methods and properties. I can build a custom class and have property names like
Name, Date, Table, Control, Form, Applicaiton .....
or methods like
Right, left,findFirst, Msgbox.....

These names will not conflict because you access those properties and methods through the class
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:21
Joined
Sep 21, 2011
Messages
14,366
TBH , I leave well alone what I do not understand. I seem to recall I did change something of your code just for my situation, but for the life of me, I cannot remember what. :(
It was not for the DB I posted.
 

ClaraBarton

Registered User.
Local time
Today, 01:21
Joined
Oct 14, 2019
Messages
479
I wasn't paying attention... Did not even realized I had done so. When it asked to save I just gave it a random name. Will NOT do it again! Thank you.
 

Users who are viewing this thread

Top Bottom