A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

need to get form property



 
 
Thread Tools Display Modes
  #11  
Old February 19th, 2010, 03:53 PM posted to microsoft.public.access.forms
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default need to get form property

The Me prefix means that what follows is a property of the form in which the
code is located. If the bang is used instead of the dot, what follows is a
member of a collection, but as noted this presents you with pretty much the
same options as you have with properties. The Me prefix by itself does not
refer to anything specific about the form, but rather sets the table for what
follows. Me.TextBox1 refers to TextBox1 no matter where it is used in the
form's code module. It could be in a form-level event such as Current, or in
an event for an individual control. Similarly, you can have a message box
display a form-level property such as the name of the form by placing this
line of code in a Click event, After Update event, form's Current event, or
wherever you like:
MsgBox Me.Name

Ron wrote:
I'm not sure I follow how you would use [MyForm].[MyField] in VBA. I
wouldn't expect anything in the immediate window. For one thing, there is
no
context.


I should have said that I'd put the form in form view after copying an
expression from within design view. Sorry.

................ If you pause code execution in a form,
you should get the value of MyField in the immediate window with any of

[quoted text clipped - 9 lines]
............ [MyForm].[MyField] and [MyForm]!
[MyField] do not work in any circumstance I can find.


Yes. Confirmed, at least after a few minutes testing.
Forms.myformname.myField works, but if you put brackets around the
collection name, then the bang operator is needed.

I prefer Me.MyField when possible if for no other reason than that the VBA
intellisense takes over (as soon as you type Me. you are presented with a
list of selections).


Good to know! I'd been wondering why intellisense wasn't popping up more.
I've shied away from Me, since I don't fully understand the contextual
requiements - eg. does Me in a control event refer to the control itself or
the form containing the control? (rhetorical; I need *really* to think in
terms of collections, objects, and properties) - but also wanted to document
this first app with full bore expressions.

Here is a discussion about the use of the bang and the dot:
http://my.advisor.com/doc/05352


Thank you! I was venting, and shouldn't have extrapolated the problems I'd
had with extended expressions to simple field syntax. (I do remain wary of
the expression builder, though.) Despite the fundamental level of threads
like this, they're valuable to me (and hopefully, to others). These groups
are great. Thanks again!


--
Message posted via http://www.accessmonster.com

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:04 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.