dim TestName as control = a module is not a valid type

bignose2

Registered User.
Local time
Today, 00:38
Joined
May 2, 2010
Messages
248
Hi,

I was trying to have a variable as a control name
I have seen lots refer to
Dim ControlXYZ as control

I get a compile error on this line, a module is not a valid type
No matter what name I use, so I know not it is not duplicated anywhere.

Sure my references are OK, never had problem with anything else.

Below does work and seems petty but I like to know why something does not work as others seem to have. Office 365
ControlXYX = "ThisControl"
frm.Controls(ControlXYZ) OK

I also think neater frm.ControlXYZ

Thanks I/A
 
Try *importing* your db into a fresh, new db and see if the issue follows.
 
Dim ControlXYZ as control

I get a compile error on this line, a module is not a valid type
I bet, you have got a module named Control in your application. Rename that module and the code should work.
It's a common practice to put the mod prefix at the beginning of every module name to avoid ambiguities.
 
That it is!

I feel such an idiot, I had this module when I first created the database 10 years ago & never noticed.

I was looking for functions with the same name but not the module itself,

Is it SAFE to rename this, I know its more of a folder but the fact the the compile picked it up makes me think it is referenced and I have a lot of functions in there.

Thanks again.
 
Is it SAFE to rename this, I know its more of a folder but the fact the the compile picked it up makes me think it is referenced and I have a lot of functions in there.
If you have got calls to functions explicitly referencing ModuleName.FunctionName in your code, you need to change those.
Compiling the code will pop up compile errors if there is a problem like that. Otherwise you should not experience any problems from renaming the module.
 

Users who are viewing this thread

Back
Top Bottom