Solved

VBA 'me.ControlName' suddenly not recognized!

Posted on 2002-07-24
12
487 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
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
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)

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

829 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