Solved

VBA 'me.ControlName' suddenly not recognized!

Posted on 2002-07-24
12
497 Views
Last Modified: 2012-05-04
Hi,

I use a lot off VBA on an access DB that has been running already for two years now, with continuing developing.

However since a few days it is coming up with problems, not excuting certain VBA codes that have been there for quite a while.

I noticed quite fast that it was every time the 'me.controlname' that 'bugged'. When I replace it with Forms!FormName.ControlName that code works again.

I have used the 'Me.ControlName' quite a lot, so changing them all would be kind off a hasle. Is there a logic explanation for this? And cam I do something about it or do I just have to change all 'Me.ControlName'?? (please not!!)

Thx a lot for your help in advance.

Ciao
bj
0
Comment
Question by:BramJan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 54

Expert Comment

by:nico5038
ID: 7175034
Did you check the references for "MISSING" libraries ?

Nic;o)
0
 

Author Comment

by:BramJan
ID: 7175214
Yep...
No "Missing" libraries.
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7175244
Then I would start with an Access re-install as it looks like the internal "me" reference is lost.

Nic;o)
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:BramJan
ID: 7175281
ah..
I guess that can't cause any problems, re-installing Access?
btw, while we are on the subject off installing, any good words regarding Access 2002? Might upgrade it at the same time then.

Thx

btw, Hoe staat het leven trouwens tegenwoordig, zomervakantie in zicht?
0
 

Author Comment

by:BramJan
ID: 7175305
ah..
I guess that can't cause any problems, re-installing Access?
btw, while we are on the subject off installing, any good words regarding Access 2002? Might upgrade it at the same time then.

Thx

btw, Hoe staat het leven trouwens tegenwoordig, zomervakantie in zicht?
0
 
LVL 57
ID: 7175348
I'm not sure how you managed to do that, but 'ControlName' is not a valid property of a form.


Jim.
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 150 total points
ID: 7175352
Also, before a re-install, you might want to simply try refreshing the references.

Open a module, click tools/references and check any reference.  Close the MDB and Access, re-open and uncheck the same reference.

Then try a compile and see if you get errors.

Jim.
0
 
LVL 13

Expert Comment

by:John Mc Hale
ID: 7176123
Is it possible that someone else is "playing around" with the name of controls on Forms.

Personally I prefer to use VBA code blocks like ...


Sub AnyButton_Click()

With Me

   .AnyControl.Caption = "Whatever"

End With

End Sub

This way, the Object Browser window will pop up, and you will know soon enough if a controls with that name exists on the Form.

HTH
0
 
LVL 4

Expert Comment

by:archery
ID: 7176389
Just a stab-in-the-dark here.

You didn't by any chance take the code that was (originally) behind the form itself, and put it into a NEW stand-alone module, did you.

The Me. ONLY works within code that is ACTUALLY within a form/report itself as it is (actually) referring to the current form/report with the focus.

(I did this once myself and suddenyl started getting runtime errors because I hadn't re-compiled my application first to check for errors, as I assumed (as I had made no ACTUAL code changes that it would work the same way, forgetting about the Me. reference).

0
 

Author Comment

by:BramJan
ID: 7177019
Hi,
Thx to all for your comments.
JDettman, i didn't mean 'ControlName' as a property on a form, but just 'a' controlname like CompanyName, which would make me.CompanyName, which 'is' a control on my form.

Your remark regarding refreshing, seems to done the job, since I tested the me.reference and it 'seemed' to work.

However I would like to leave the question open for 1 or 2 days to see if it doesn't occur again and if I'm right that it is ok now. since it is quite a big db and not possible for me to go though all the forms.

Thx again for your help and I'll be back, please don't hesitate to leave any other comments.

Ciao
bj
0
 
LVL 57
ID: 7177072
<<JDettman, i didn't mean 'ControlName' as a property on a form, but just 'a' controlname like CompanyName, which would make me.CompanyName, which 'is' a control on my form.
>>

  That makes more sense.  I always forget that from A97 up, that controls can be referenced like a property.  Old Habits die hard and I still use ! for object references and . for properties only.  Had me thinking in the wrong direction.  

<<Your remark regarding refreshing, seems to done the job, since I tested the me.reference and it 'seemed' to work.>>

 Yes, the references are not always marked "MISSING" or "BROKEN" even though they really are not correct.  The check/uncheck forces Access to refresh the references collection and fix any problems.  Keep it in mind anytime you start to have problems with built-in functions or properties/methods.

Jim.
0
 

Author Comment

by:BramJan
ID: 7206459
Haven't had the problems anymore since i did this. So I guess that was the solution. I still think that Bill Gates should be notified of this, because it is again weird bug  that doesn't make any sence, which i encounter more and more these days, those unexplainable bugs.

but jim, THX!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question