??????????

FCVIII

Registered User.
Local time
Today, 06:23
Joined
Jun 13, 2002
Messages
14
What does Me. or Me! refer to?
 
In certain circumstances (most notably in VBA code), you want to make a generic subroutine or function. This generic procedure might need to take an action that applies to the form or report that called it, but finding that out can be tricky.

In that context, you can use Me

Suppose that you have a VBA subroutine that writes a new value into a text box but doesn't change the current record. You can force the text box to be refreshed with Me.Repaint

If you wish to step through the controls on a form, you can write code based on Me, as

Dim ctlNxt as Control

For Each ctlNxt in Me.Controls .....


When you know the name of the form (as you would for VBA code in a class module), you don't necessarily need Me. But when the code is in a general module, Me can be a great convenience.

Want to find out the name of the form that called your function or procedure? Me.Name tells you.

Does that help?
 
More??????????

So Me! Refers to the active Form/Report/Table/Whatever

So IF I always write out the path I technically wont need it
 
????=oohh's and ahhs

Crystal ....Thanks a lot


Ill be back with more questions
 
Me is shorthand for "the Form or Report that holds the code context in which this code is running." So if you went through the Database.Forms("name") syntax, you would always be able to avoid the use of Me. BUT if you are like me, often cutting and pasting common routines into new applications from text files, you can build them with Me rather than the long name and they work just as well.

(FYI - if you ever read one of my comments about a "toolkit", the idea of having canned code snippets to include in new .MDB files is part of the toolkit concept - and a good idea to prevent you from having to re-invent too many wheels. But that is a side issue...)

Another valuable use: Me can be an argument to a public function designed in a general module. If that argument would be a form or report, it saves scads of typing.

As Pat points out, Me is never a table, macro, or query - because none of those things has a code context in which Me could exist.
 

Users who are viewing this thread

Back
Top Bottom