Me! or Me. ???

jaythom

New member
Local time
Today, 15:14
Joined
Aug 16, 2003
Messages
7
Hello everyone,

I had been using Me.[etc] for a long time before showing my code to another person who said I should begin using Me![etc] instead. I have changed over and began doing this, but I am unsure what benefit this has. The only thing I did notice was that the names don't autoexpand when using the '!'.

Does anyone have any opinions on what they use or what they have experienced?

Thanks!

JT
 
jaythom said:
another person who said I should begin using Me![etc] instead

They told you that without giving a justification?
 
Using the dot syntax (early binding) asks VBA to work out the object’s nuances at compile time meaning that the application knows exactly what is expected of objects as it has, basically, predetermined their characteristics beforehand which can dramatically increase the speed of your application.

Using the exclamation mark syntax (late binding) allows your application to compile but the application determines the objects at runtime, and the time taken to determine can increase performance time as you are essentially asking VBA to use an object but it must first decide what sort of object it is.

i.e.

Me.txtMyTextbox

This line allows VBA to know we are referring to the form and it knows the object txtMyTextbox is a textbox and thusly allows you access to its methods and properties.

Me!txtMyTextbox

This line is asking VBA to work out what sort of object txtMyTextbox and then evaluate it.

For optimising your database then you should really use early binding. The only caveat with using early binding is that it requires the reference libraries to compile. If you don’t have the references to these libraries then the application’s compilation will fail. The only time, to be honest, that you should use late binding is when a component does not support early binding.

Go tell the person that they are wrong. ;)
 
Hi, sorry for butting in on your post but I think this is related, and I've kept meaning to ask!

What is the difference in

me.textbox1 = "hello" or

and

textbox1.value = "hello"

I've always used textbox1.whatever as against me.textbox

CALV
 
Calv, there's no real difference.

The default property of a textbox is .Value

Therefore you can state the textbox on its own:

i.e.

Me.txtMyTextbox

and, as Value is its default property, this is evaluated thusly:

Me.txtMyTextbox.Value



The same thing, basically just that one is implicit; the other explicit.

:cool:
 
I allways use Me.control.whatever
for a number of reasons not the least of which is to make clear to anyone and everyone we are talking about a control on the form and not some variable set in de code....

Regards
 
Access translates all "bang" notation into "dot" notation at runtime, so the "dot" notation is typically faster.

As far as the discussion regarding "Me.txtMyTextbox.Value", that's actually a shortcut to Me.Controls("txtMyTextbox").Value, the controls collection is the default collection for form objects so it's implicitly understood (sometimes not :D ). Then again, Me is just a shortcut to the current form running your code.
 

Users who are viewing this thread

Back
Top Bottom