Solved

VBA 'me.ControlName' suddenly not recognized!

Posted on 2002-07-24
12
468 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
  • 5
  • 3
  • 2
  • +2
12 Comments
 
LVL 54

Expert Comment

by:nico5038
Comment Utility
Did you check the references for "MISSING" libraries ?

Nic;o)
0
 

Author Comment

by:BramJan
Comment Utility
Yep...
No "Missing" libraries.
0
 
LVL 54

Expert Comment

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

Nic;o)
0
 

Author Comment

by:BramJan
Comment Utility
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
Comment Utility
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

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
I'm not sure how you managed to do that, but 'ControlName' is not a valid property of a form.


Jim.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 150 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Expert Comment

by:Jim Dettman (Microsoft MVP/ EE MVE)
Comment Utility
<<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
Comment Utility
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now