Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

As Controls "Type MIsmatch" 1

Status
Not open for further replies.

zevw

MIS
Jul 3, 2001
697
US
This is my code and it worked fine on all machines.

Code:
Dim ctl As Control
        
For Each [COLOR=red]ctl In Controls[/color]
    Code.....
Next

Yesterday I got a complaint from the users that the cannot run this form, so I ran it in debug mode and I got a message "Run Type Error 13 Type Mismatch".

I changed the line "Dim ctl As Control" to "Dim ctl" and it works fine.

My question is what should I look for when I get this error and how can I reset it to AS Control? I tried changing the variable name but that did not help either.

Thanks in advance for your help!!!
 
cannot run this form
Which kind of form in which application ?
Just a guess:
Dim ctl As MSForms.Control

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Or maybe?

For Each ctl In Me.Controls

more likely PHV is correct.

In any case, yes, please always state what kind of form, and most definitely always state what application.

Gerry
My paintings and sculpture
 
I don't understand what you mean by which application.

The only thing I can answer is Access 2002 SP3

I tried with MSForms.Control

and I get an error "User-defined type not defined
 
So, the application is Access:
Dim ctl As Access.Control
For Each ctl In Me!Controls
Code.....
Next

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks it works great!

May I ask if you can explain to me why when I declared it without the Access.Control it wouldn't work?

What could have changed 2 days ago that the As Control stopped working only on this machine?

Thanks for all your help!!
 
Probably a new object library referenced that contain a Control object too.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top