473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Referencing Controls on a Form (Dot v Bang)

NeoPa
32,556 Expert Mod 16PB
...First whenever reffering to a control on a form you are currently in then you should always refer to it by using Me!

Such as: Me!txtPassword.SetFocus
...
You sound as if you know where you're coming from.
Without hijacking the thread too much, What is your position on Me.Control versus Me!Control?
Until recently, I would have said Me! was the correct way (both work generally of course). Then I considered that, although the controls are not defined properties of an Access.Form class, they are defined properties of the Form_YourFormName 'derived' class. I'd be interested in your comments.
Mar 16 '07 #1
16 5474
Denburt
1,356 Expert 1GB
NeoPa
Until recently? Changed your oppinion... Unless there is something in the most recent version that i'm unaware of and from what I know it is basically the proper way of coding. I have inherited many databases over the years and have had issues with such coding practices.

Here are some different ways of refering to controls.
I have read articles that explicitly state that ME!Control is quicker than me.controls("Control") or other methods although I do use me(myVariable) quite often to change properties on a number of controls for dynamic purposes.

http://msdn2.microsoft.com/en-us/lib...ffice.11).aspx
Mar 16 '07 #2
NeoPa
32,556 Expert Mod 16PB
NeoPa
Until recently? Changed your oppinion... Unless there is something in the most recent version that i'm unaware of and from what I know it is basically the proper way of coding. I have inherited many databases over the years and have had issues with such coding practices.
Yes. Recently, after seeing it used both ways, I tried to figure out for myself which is the 'correct' way. MS often provide more than one way to reference something and this is no exception.
Here are some different ways of refering to controls.
I have read articles that explicitly state that ME!Control is quicker than me.controls("Control") or other methods although I do use me(myVariable) quite often to change properties on a number of controls for dynamic purposes.
My interest is not so much in the comparison between Me! & various other methods (No arguments with performance issues quoted btw), but between Me! & Me. specifically.
http://msdn2.microsoft.com/en-us/lib...ffice.11).aspx
Thanks for this link. It does sound as if the Me! is absolutely the 'most' correct way to specify an individual named instance of a control. Unfortunately, it still leaves questions unanswered.
  1. Why does Me. work at all?
  2. Why does the properties list only display in the VBA window when Me. is used?
  3. If the designed form in a database (Let's call it [frmThis] for convenience) is a derived class (From the Form class) then the controls on the form are properties of the [Form_frmThis] class itself surely - as well as being members of (but not restricted to) the Controls collection?
I can't help feeling that someone has missed something somewhere (Yes, even someone from MS itself possibly - Internal communication is rarely perfect in large organisations at the best of times).

Before I sign off, let me thank you for responding. Though I rarely accept anything at face value, I still appreciate your response :)
Mar 16 '07 #3
Denburt
1,356 Expert 1GB
LOL, Yes this had me for a long time and since I am self taught and using programming for more years than I want to count and currently on a long term contract for office automation. I tend to do as much research as possible for things (ANYTHING) that get under my claw.

OK from what I understand it is a property but also an object however when you are referring to it as a property you would use the me. as an object me! yada yada Therefore me!mycontrol.setfocus should be a gaurantee where me.mycontrol generally shouldn't but sometimes will (I am guessing auto correct).

1. OK although not a hundred percent but pretty sure that the reason me. works when referring to it as an object is because of MS accesses flexibility and the autocorrect functions of the program. Since this would have to be taken into consideration i am quite sure that Me! would not only be more direct but quicker.

2. The period lets the program know that you are accessing the properties of the object you are using thus the properties window is displayed.

3. If I understand correctly I believe I agreed earlier in this post.

You are quite welcome and I am more than happy to respond I hope you don't mind me quoting you but I also rarely accept anything at face value, and I am more than happy to share my views and or knowledge. Thanks for the questions.
:)
Mar 16 '07 #4
NeoPa
32,556 Expert Mod 16PB
Denburt,
I'm sorry I'll have to move this post later as it seems it's less straightforward than I anticipated. It can be done mind, but I need to rush out shortly so will do it later.
I'll give better consideration to your (obviously quite thorough) answer then too if I may. I look forward to it. In fact I may print a hard-copy so won't have to wait so long :)
Mar 16 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
Very interesting discussion guys!

Denburt if you get the time could you put an article together for the articles forum here. I can then create a link to it in the Tutorials on Access and VBA
thread.

Mary
Mar 17 '07 #6
Rabbit
12,516 Expert Mod 8TB
We could always run a simulation to see whether Me! or Me. is faster. Say access the property 100,000 times and compare the time it takes to finish.
Mar 17 '07 #7
NeoPa
32,556 Expert Mod 16PB
LOL, Yes this had me for a long time and since I am self taught and using programming for more years than I want to count and currently on a long term contract for office automation. I tend to do as much research as possible for things (ANYTHING) that get under my claw.

OK from what I understand it is a property but also an object however when you are referring to it as a property you would use the me. as an object me! yada yada Therefore me!mycontrol.setfocus should be a gaurantee where me.mycontrol generally shouldn't but sometimes will (I am guessing auto correct).

1. OK although not a hundred percent but pretty sure that the reason me. works when referring to it as an object is because of MS accesses flexibility and the autocorrect functions of the program. Since this would have to be taken into consideration i am quite sure that Me! would not only be more direct but quicker.

2. The period lets the program know that you are accessing the properties of the object you are using thus the properties window is displayed.

3. If I understand correctly I believe I agreed earlier in this post.

You are quite welcome and I am more than happy to respond I hope you don't mind me quoting you but I also rarely accept anything at face value, and I am more than happy to share my views and or knowledge. Thanks for the questions.
:)
Right.
Back to my post at last :)
It seems to me, without wishing to flog a dead horse, the the crux of the question is "Is it a property of the derived form object - or not?"
Your answer to question 1 is certainly a possibility, as I know that Access is very forgiving, when it can be. This is merely evidence for it being a possibility though, it doesn't so much support the position as fail to undermine it.
However, as you say yourself in your answer to question 2, the period triggers a list of properties to be shown and Me. shows all the created controls in the list. This seems to me to imply (quite strongly actually) that, even though controls can be referenced via the Controls collection (Using ! to indicate a shortcut syntax if preferred), they are nevertheless properties in their own right.
I presume, from your answer to question 3, that you're happy that they are, indeed, direct properties of the object. Does this mean that you're comfortable with the Me. syntax generally? (I'm not trying to put words into your mouth ;))

Mary,
There is another post (the last one) in the other thread that really belongs in here. If you know how to do that easily, could you move it across. The only way that I could think of to do that would be to merge then resplit the threads.

Rabbit,
Unless both syntax versions were examples of late-binding, I'm not sure that any difference in time would be reflective of the issues we're discussing. It's a neat idea though :)
Mar 17 '07 #8
MMcCarthy
14,534 Expert Mod 8TB
Mary,
There is another post (the last one) in the other thread that really belongs in here. If you know how to do that easily, could you move it across. The only way that I could think of to do that would be to merge then resplit the threads.
Done.

For future reference, split out the posts into a temp thread then merge the temp thread with this one.

Mary
Mar 17 '07 #9
NeoPa
32,556 Expert Mod 16PB
That's a good idea. I was thinking I'd have to merge before re-splitting. Having a Blond moment.
Unlucky on the rugby result btw - I was rooting for you. We were cr*p :(
Mar 17 '07 #10
MMcCarthy
14,534 Expert Mod 8TB
That's a good idea. I was thinking I'd have to merge before re-splitting. Having a Blond moment.
Unlucky on the rugby result btw - I was rooting for you. We were cr*p :(
Yeah I guess it just wasn't meant to be. The last try by France, try or no try?
Mar 17 '07 #11
NeoPa
32,556 Expert Mod 16PB
Yeah I guess it just wasn't meant to be. The last try by France, try or no try?
Much as I hated to see it, I'm sure it was a try.
Mar 19 '07 #12
Denburt
1,356 Expert 1GB
O.K. Mary yes I would love to put together an article for you I would like to finish a little research first and verify it in a few more tests.

OK Rabbit this ones for you.
Right now its late but here is the early results of my tests.

Using Forms!Main_Menu!FormsBut took merely 12 sec

Using Forms!Main_Menu.FormsBut took 15 sec

Rran it 4 times both ways same results exactly, I still have a few more things in mind to try though.
This was a toggle button on a form btw.

Expand|Select|Wrap|Line Numbers
  1. Private Sub DoMe()
  2. Dim Cnt As Long
  3. Do Until Cnt = 100000
  4. If Forms!Main_Menu.FormsBut = 0 Then
  5. Forms!Main_Menu!FormsBut = -1
  6. Else
  7. Forms!Main_Menu!FormsBut = 0
  8. End If
  9. Cnt = Cnt + 1
  10. Loop
  11. End Sub
Mar 20 '07 #13
NeoPa
32,556 Expert Mod 16PB
Inspired to check this out for myself, I used the following code :
Expand|Select|Wrap|Line Numbers
  1. Private Sub chkVoy2_Click()
  2.     Dim lngIdx As Long
  3.  
  4.     Debug.Print Now()
  5.     For lngIdx = 1 To 500000
  6.         Me!chkVoy2 = Not Me!chkVoy2
  7.     Next lngIdx
  8.     Debug.Print Now()
  9.     For lngIdx = 1 To 500000
  10.         Me.chkVoy2 = Not Me.chkVoy2
  11.     Next lngIdx
  12.     Debug.Print Now()
  13. End Sub
I found that, depending on where I put the various elements, the differences varied.
The last set I got was :
Expand|Select|Wrap|Line Numbers
  1. 20/03/2007 12:55:15
  2. 20/03/2007 12:55:59
  3. 20/03/2007 12:56:44
...but every other time there was a 2/3 second gap with the '.' version always taking longer. This is merely an interesting exercise as far as I'm concerned though, as I don't see it having any bearing on the fundamental issue.
Another point worth making though, is that the Me! version (on Access 2000 at least) DID bring up the list of controls available, contrary to what I posted earlier.
Mar 20 '07 #14
Denburt
1,356 Expert 1GB
I presume, from your answer to question 3, that you're happy that they are, indeed, direct properties of the object. Does this mean that you're comfortable with the Me. syntax generally? (I'm not trying to put words into your mouth )
First I wanted to make sure I clarified this for you, um no. Yes I do agree that they are considered a property of that form, however calling an object using a properties syntax just rubs me wrong to say the least.

Most of my apps are usually resource hogs to begin with so if there is anything I can to streamline it and get an extra millisecond of time I try to do it. I have been looking and searching and racking my brain to see if there is a way to use the control as a property of the form yet I am still coming up stumped so far.

Give me just a little more time and I will make that post for you Mary I just like to be sure I do my research and I always like to back up my opinions with facts.
Mar 20 '07 #15
MMcCarthy
14,534 Expert Mod 8TB
First I wanted to make sure I clarified this for you, um no. Yes I do agree that they are considered a property of that form, however calling an object using a properties syntax just rubs me wrong to say the least.

Most of my apps are usually resource hogs to begin with so if there is anything I can to streamline it and get an extra millisecond of time I try to do it. I have been looking and searching and racking my brain to see if there is a way to use the control as a property of the form yet I am still coming up stumped so far.

Give me just a little more time and I will make that post for you Mary I just like to be sure I do my research and I always like to back up my opinions with facts.
No problem. If you don't get it right some argumentative members (not mentioning any names Ade) will feel honour bound to find the holes in it for you.

Mary
Mar 20 '07 #16
NeoPa
32,556 Expert Mod 16PB
I seem to come at this from the opposite direction. I would look to use a predefined property of a specific form (Object or otherwise) first as a property of the form. That's not to say I can only conceive of that way being correct.
Most of my apps are usually resource hogs to begin with so if there is anything I can to streamline it and get an extra millisecond of time I try to do it. I have been looking and searching and racking my brain to see if there is a way to use the control as a property of the form yet I am still coming up stumped so far.
I must be missing something here. I would think that using Me. would be referring to the control as a property of the form. I'm sure you must mean something different from what I understand you to be saying.
Anyway - it's nearly 19:00 so I should be getting off home :(
Mar 20 '07 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Data Guy | last post by:
In my approach to validation for widgets, i write javascript functions. At the end of the document, inside the form, i invoke the function as <FORM NAME="testit"> <INPUT TYPE="TEXT" VALUE="2"...
3
by: shumaker | last post by:
This code from the subform works for getting the value of a field of the main form named "WorkSheet": MsgBox Form_WorkSheet.Recordset.Fields("Clerk").Value Each record in the mainform datasheet...
4
by: mplogue | last post by:
I have a form (frmMain) with a subform (frmSub), each with enumerated fields of the same name (txt1, txt2, etc). I'm trying to make a function that will take the values for each field in frmMain,...
1
by: Will | last post by:
Hi all. I'm learning VB.Net and am developing a WinForms app. I'm trying to make an app that I will use to scan in one or more than on image. I want to use a tabbed interface to hold each image....
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
2
by: Axel | last post by:
Hi, a question about something that seems very simple at first glance: is it possible to reference other controls of a subform in a query window without referencing through the parent form? I...
21
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main...
2
by: ccsnavy | last post by:
For some reason referencing an unbound control on an active form from a query has ceased to work correctly. While other previously existing references to unbound controls in the same form seem to...
5
kcdoell
by: kcdoell | last post by:
Good Morning: I am using the following code to add new records to a table that is on my Sub Form. Below is the code that I placed in my Before Update event on my Sub Form: Private Sub...
2
by: joancabianna | last post by:
Hello, What I am trying to do is have one form loop through its combo boxes and check to see if the value is a key word like Query_Form or Query_Form2. What I then want to happen is in either case...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.