compile error: qualifier must be a collection (1 Viewer)

aivars

New member
Local time
Today, 08:52
Joined
May 23, 2015
Messages
15
It used to work OK. Now for some time it throws an error, as per attached picture. It happens not only in this form, but in others as well. Tried to use [], without [], imported/exported the forms, used Application.SaveAsText/Application.LoadFromText, even made a fresh frontend file. Nothing works.
What could be wrong?
Win 10, Access 2021LTSC, version 2207
 

Attachments

  • Clipboard01.jpg
    Clipboard01.jpg
    29.8 KB · Views: 75

CJ_London

Super Moderator
Staff member
Local time
Today, 06:52
Joined
Feb 19, 2013
Messages
16,658
looks like you have a space after the !

usual way to assign would be

set rpt=reports(reportname)
 

aivars

New member
Local time
Today, 08:52
Joined
May 23, 2015
Messages
15
Thanks, @CJ_London, now a new error popping up!
 

Attachments

  • Screenshot 2022-08-31 122934.png
    Screenshot 2022-08-31 122934.png
    22 KB · Views: 73

aivars

New member
Local time
Today, 08:52
Joined
May 23, 2015
Messages
15
Just found out that I had to put Access.Reports(reportName), Access.Forms etc... in the code, and no more errors!!
Why it worked before and then not?
 

sonic8

AWF VIP
Local time
Today, 07:52
Joined
Oct 27, 2015
Messages
998
Just found out that I had to put Access.Reports(reportName), Access.Forms etc... in the code, and no more errors!!
Why it worked before and then not?
Any chance you recently introduced a new global variable or a new control named "Reports" into your project/form? - That would explain this.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:52
Joined
Feb 28, 2001
Messages
27,303
Is there a chance that you added a new library to your references recently? Or a new version of an older library? And could that library have contained "Reports" as one of its elements? Or has someone altered the order in which a given library is referenced? Do you have a new table that has the name "Reports"?

Because that behavior (requiring Access.xxx vs. xxx) says that there is a name confusion. I.e. if it didn't work at all, that would be one thing. But if merely providing a qualifier prefix solves the problem, the problem was ambiguity.

By way of explanation, back when DAO and ADO libraries both had to be referenced to use them, if you used an unqualified "recordset" then you got whichever flavor was matched first, and the two types of recordset WERE different. But they coexisted quite well if you used the right qualifiers during object declaration.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 01:52
Joined
May 21, 2018
Messages
8,567
Any chance you recently introduced a new global variable or a new control named "Reports" into your project/form? - That would explain this.
@aivars that "fix" is a band aid for the problem as @sonic8 is pointing out. You really should find where this problem is coming from and fix it, or this can cause some real confusion. You most likely have a naming conflict somewhere

I doubt it is a control names "Reports" because it happens on all forms. It is highly likely a public (global) variable at the module level
I can easily replicated this doing that.
Collection.png


Why adding "Access" to this fixes it is because now you specifically qualified it. You are telling the code to look in the Access library for a property named "Reports"
 

KitaYama

Well-known member
Local time
Today, 14:52
Joined
Jan 6, 2022
Messages
1,567
I had a simillar problem with visible and enabled.
I didn't receive any error and everything worked perfect, but after compiling, they didn't convert to proper case and stayed with lower case.
myControl.visble=True

A search on this forum brought up this post. I seaerched and found a function with two parameters : visible and enabled :
Rich (BB code):
Private Function myFunction (visible as Boolean, enabled as Boolean) as Boolean

After changing the parameters, everything was back.
 
Last edited:

sonic8

AWF VIP
Local time
Today, 07:52
Joined
Oct 27, 2015
Messages
998
I had a simillar problem with visible and enabled.
Your issue is not similar at all.
VB(A) is a case insensitive language.
The VBA editor tries to adjust the casing of identifiers (variable, method, and property names) used in the code to the casing of the definition of the identifier. It sometimes gets confused if there are several identical identifiers with different casing in different scopes.
However, the "proper" casing has no effect on the compilation and execution of the code whatsoever.
 

KitaYama

Well-known member
Local time
Today, 14:52
Joined
Jan 6, 2022
Messages
1,567
Your issue is not similar at all.
By similar I meant similar in bad choice of naming variable/parameter.
If OP's problem is caused by what you or MajP showed, both of our problem goes back to using bad names for variables/parameters. In that sense my problem was similar to his.
 
Last edited:

aivars

New member
Local time
Today, 08:52
Joined
May 23, 2015
Messages
15
Thanks everybody for the feedback. I'll try to follow the advice and check what happened.
Will report back.
 

aivars

New member
Local time
Today, 08:52
Joined
May 23, 2015
Messages
15
good evening,
I have found the problem.
It was/is Enum definition in a function ListObjects I took recently from https://www.devhut.net/ms-access-listing-of-database-objects/
Enum ObjectType
Tables_Local = 1
Tables_Linked_ODBC = 4
Tables_Linked = 6
Queries = 5
'Forms = -32768
'Reports = -32764

Macros = -32766
Modules = -32761
End Enum

Commenting out both Forms and Reports solves my problem. That function is great too but I have to re-write it without Enum somehow
Should I tell this to Daniel? His site is excellent.

Thanks everybody and to @MajP who's example led me to narrow the field.
It made me re-think a lot about programming in general...
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 01:52
Joined
May 21, 2018
Messages
8,567
The standard for Enum naming is a two letter prefix and the same for the values. Probably to help with naming conflicts like this. Example in the openform there is an argument for windowmode. That uses the Enum acWindowmode. This has values acdialog, achidden, etctc. You will see most enums start with ac in Access, vb in vba, xl in Excel.
If you still want to use this consider prefixing. Maybe "acot" for Access object type. So acotObjectType, acotForm, acotReprt etc.
 

Users who are viewing this thread

Top Bottom