Solved

VBA 'me.ControlName' suddenly not recognized!

Posted on 2002-07-24
12
484 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

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…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

777 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