473,385 Members | 2,044 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,385 software developers and data experts.

Help with understanding order of For Each Control

Hello,

Does anyone here know for sure, when you do a For Each loop on a forms
controls collection, does Access cycle through them in Alphabetical order or
control ID or ???.

Any ideas?

Thanks!
Nov 13 '05 #1
12 5544
rkc
Jozef wrote:
Hello,

Does anyone here know for sure, when you do a For Each loop on a forms
controls collection, does Access cycle through them in Alphabetical order or
control ID or ???.

Any ideas?


For some reason I think it's in the order they were created.
Obviously I don't now for sure. I just think that.
Nov 13 '05 #2
On Wed, 12 Oct 2005 19:29:05 GMT, "Jozef" <me@you.com> wrote:

I believe the order is undocumented. If you need a specific order,
you better do the work yourself: collect the controls in an array or
collection, sort them the way you want, and process them that way.

-Tom.

Hello,

Does anyone here know for sure, when you do a For Each loop on a forms
controls collection, does Access cycle through them in Alphabetical order or
control ID or ???.

Any ideas?

Thanks!


Nov 13 '05 #3
Most likely it corresponds to creation sequence as that is when it would be
added to the forms controls collection, but as Tom says "If you need a
specific order ..."

Terry Kreft
"Tom van Stiphout" <no*************@cox.net> wrote in message
news:ot********************************@4ax.com...
On Wed, 12 Oct 2005 19:29:05 GMT, "Jozef" <me@you.com> wrote:

I believe the order is undocumented. If you need a specific order,
you better do the work yourself: collect the controls in an array or
collection, sort them the way you want, and process them that way.

-Tom.

Hello,

Does anyone here know for sure, when you do a For Each loop on a forms
controls collection, does Access cycle through them in Alphabetical order
or
control ID or ???.

Any ideas?

Thanks!

Nov 13 '05 #4
"Terry Kreft" <te*********@mps.co.uk> wrote in
news:ol********************@karoo.co.uk:
Most likely it corresponds to creation sequence as that is when it
would be added to the forms controls collection, but as Tom says
"If you need a specific order ..."


Isn't it the same as the z order? That is, if you use BRING TO
FRONT, does it not change the order?

Of course, I'm not sure why you'd ever need a collection processed
in a particular order == that rather defeats the purpose of
collections.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #5
rkc
David W. Fenton wrote:
"Terry Kreft" <te*********@mps.co.uk> wrote in
news:ol********************@karoo.co.uk:

Most likely it corresponds to creation sequence as that is when it
would be added to the forms controls collection, but as Tom says
"If you need a specific order ..."

Isn't it the same as the z order? That is, if you use BRING TO
FRONT, does it not change the order?

Of course, I'm not sure why you'd ever need a collection processed
in a particular order == that rather defeats the purpose of
collections.


Have you never used an Order By clause in the SQL used to retrieve a
Recordset? What does that do if not determine the order in which data
is stored in the Fields Collection? Why would you do that if you didn't
want to process the 'collection' in a particular order?

Nov 13 '05 #6
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:gv*******************@twister.nyroc.rr.com:
David W. Fenton wrote:
"Terry Kreft" <te*********@mps.co.uk> wrote in
news:ol********************@karoo.co.uk:
Most likely it corresponds to creation sequence as that is when
it would be added to the forms controls collection, but as Tom
says "If you need a specific order ..."


Isn't it the same as the z order? That is, if you use BRING TO
FRONT, does it not change the order?

Of course, I'm not sure why you'd ever need a collection
processed in a particular order == that rather defeats the
purpose of collections.


Have you never used an Order By clause in the SQL used to retrieve
a Recordset? What does that do if not determine the order in
which data is stored in the Fields Collection? Why would you do
that if you didn't want to process the 'collection' in a
particular order?


Er, what?

A SQL resultset is not a collection, except colloguially speaking.

I was speaking of collections in the sense used in the object models
for automating Access, and DAO and VBA. In those contexts,
collections are, by definition, unordered.

I still can't figure out why you'd need to process the controls
collection in any particular order. The much greater problem is all
the things in that collection that you usually need to ignore (like
labels, for instance).

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #7
rkc
David W. Fenton wrote:
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:gv*******************@twister.nyroc.rr.com:

David W. Fenton wrote:
"Terry Kreft" <te*********@mps.co.uk> wrote in
news:ol********************@karoo.co.uk:
Most likely it corresponds to creation sequence as that is when
it would be added to the forms controls collection, but as Tom
says "If you need a specific order ..."

Isn't it the same as the z order? That is, if you use BRING TO
FRONT, does it not change the order?

Of course, I'm not sure why you'd ever need a collection
processed in a particular order == that rather defeats the
purpose of collections.
Have you never used an Order By clause in the SQL used to retrieve
a Recordset? What does that do if not determine the order in
which data is stored in the Fields Collection? Why would you do
that if you didn't want to process the 'collection' in a
particular order?

Er, what?

A SQL resultset is not a collection, except colloguially speaking.


SQL Resultset?

What good would a ->dao.recordset<- be without the fields collection?
The whole purpose of a recordset is to support operations on the Fields
collection.

I was speaking of collections in the sense used in the object models
for automating Access, and DAO and VBA. In those contexts,
collections are, by definition, unordered.


Point to documentation that says that.

This is from the VBA help file:

<quote>
Collection Object

A Collection object is an ordered set of items that can be referred to
as a unit.
</quote>

Nov 13 '05 #8
David,
Yes you're right it is the zorder, that is insane (IMO).

I agree the best method to process a collection is to use the key to refer
to elements, but the sequence is also important hence my comment that basing
the sequence on zorder is insane.
--
Terry Kreft

"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@216.196. 97.142...
"Terry Kreft" <te*********@mps.co.uk> wrote in
news:ol********************@karoo.co.uk:
Most likely it corresponds to creation sequence as that is when it
would be added to the forms controls collection, but as Tom says
"If you need a specific order ..."


Isn't it the same as the z order? That is, if you use BRING TO
FRONT, does it not change the order?

Of course, I'm not sure why you'd ever need a collection processed
in a particular order == that rather defeats the purpose of
collections.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc

Nov 13 '05 #9
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:ur*******************@twister.nyroc.rr.com:
David W. Fenton wrote:
rkc <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in
news:gv*******************@twister.nyroc.rr.com:

David W. Fenton wrote:

"Terry Kreft" <te*********@mps.co.uk> wrote in
news:ol********************@karoo.co.uk:
>Most likely it corresponds to creation sequence as that is when
>it would be added to the forms controls collection, but as Tom
>says "If you need a specific order ..."

Isn't it the same as the z order? That is, if you use BRING TO
FRONT, does it not change the order?

Of course, I'm not sure why you'd ever need a collection
processed in a particular order == that rather defeats the
purpose of collections.

Have you never used an Order By clause in the SQL used to
retrieve a Recordset? What does that do if not determine the
order in which data is stored in the Fields Collection? Why would
you do that if you didn't want to process the 'collection' in a
particular order?

Er, what?

A SQL resultset is not a collection, except colloguially
speaking.


SQL Resultset?

What good would a ->dao.recordset<- be without the fields
collection? The whole purpose of a recordset is to support
operations on the Fields collection.


I misread you as speaking about the ORDER BY clause of SQL, sorry!

In any event, you use the Fields collection to refer to the items in
that collection *by name* not by order, so the ordering of the
*collection* is irrelevant to ordering the resultset.

If you are depending on the order of the Fields collection, I think
you're doing it the hard way! The only case I'd ever use index
numbers for working with fields in a reacordset is when I knew the
field names could be different each time. Then I'd have to be very
careful to make sure the fields were in the correct order, which
cannot be done with the collection itself, but only with outside
information (i.e., I know what order I put the fields in the SELECT
clause).
I was speaking of collections in the sense used in the object
models for automating Access, and DAO and VBA. In those contexts,
collections are, by definition, unordered.


Point to documentation that says that.

This is from the VBA help file:

<quote>
Collection Object

A Collection object is an ordered set of items that can be
referred to as a unit.
</quote>


Hmm. I don't understand that use of the word "ordered", except if it
means "arbitrarily ordered."

For practical purposes, I think anyone who is depending on the order
of a collection for any purpose whatsoever is probably making a
mistake, as there are just too many things that can change the
membership and ordering of the collection.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #10
"Terry Kreft" <te*********@mps.co.uk> wrote in
news:FE********************@karoo.co.uk:
I agree the best method to process a collection is to use the key
to refer to elements, but the sequence is also important hence my
comment that basing the sequence on zorder is insane.


Well, if you need a collection in a different order, you're going to
have to create it yourself.

I still don't quite understand the concept of processing a
collection in order -- to me, operations on collections are set
operations that are performed sequentially. The order shouldn't
matter. If it *does* matter, then I think you're making a mistake
unless you're using your own custom collection with your own defined
ordering.

And I *still* don't understand why the order of processing would
ever make any difference whatsoever.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #11
Writing some audit code, and I figured if the collection was processed
sequentially in a For each loop that I could set the array to the
controlsource and value of the field, should the field have a control
source. I was looking to see how lean I could make the code, as in if the
array was documented to be processed in that order every time, then I could
just check the differences without having to loop through the array to find
the controlsource or field name.

I like this group, and I mean no disrespect to anyone when I say this, but I
think it's funny how many people speculate at what you are trying to acheive
or why, or ask somewhat unrelated questions when questions are posted or
give an answer or statement that is well outside the scope of the original
question. Not critisizing, just an observation that I find rather funny.

Thanks for your reponse!

"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@216.196. 97.142...
"Terry Kreft" <te*********@mps.co.uk> wrote in
news:FE********************@karoo.co.uk:
I agree the best method to process a collection is to use the key
to refer to elements, but the sequence is also important hence my
comment that basing the sequence on zorder is insane.


Well, if you need a collection in a different order, you're going to
have to create it yourself.

I still don't quite understand the concept of processing a
collection in order -- to me, operations on collections are set
operations that are performed sequentially. The order shouldn't
matter. If it *does* matter, then I think you're making a mistake
unless you're using your own custom collection with your own defined
ordering.

And I *still* don't understand why the order of processing would
ever make any difference whatsoever.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc

Nov 13 '05 #12
"Jozef" <me@you.com> wrote in news:nE94f.13820$y_1.121@edtnps89:
I like this group, and I mean no disrespect to anyone when I say
this, but I think it's funny how many people speculate at what you
are trying to acheive or why, or ask somewhat unrelated questions
when questions are posted or give an answer or statement that is
well outside the scope of the original question. Not critisizing,
just an observation that I find rather funny.


Well, those kinds of questions are of the "give you a fish vs. teach
you to fish" variety. We could answer your question and you'd go
away with a solution. Or, we can consider the *why* behind the
question and look at whether or not you'd be better re-engineering
away the problem in the first place.

It's like the guy who goes to the doctor and says "when I do this it
hurts. What should I do, Doctor?" and the doctor says "Don't do
that!" That stops the symptom, but doesn't ge rid of whatever it is
that's causing the pain.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: serge calderara | last post by:
Dear all, I ma collected data from a CSV file and build dataset based on those data. I would like to bind this dataset to a treeview control in order that nodes gets displayed automatically...
3
by: Mike | last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or comments on how to make this work I would be grateful! I have been working on this for the past 4 days and nothing I do...
5
by: TD | last post by:
Hey All, I am hooking up our custom html (.chm) help file to our Access xp application, and, despite reading several posts and manuals on this, I still have a gap in my understanding... OK, so...
13
by: Chua Wen Ching | last post by:
Hi there, I saw this article here in vb.net. http://www.error-bank.com/microsoft.public.dotnet.languages.vb.1/148992_Thread.aspx and ...
22
by: Jeff Louie | last post by:
Well I wonder if my old brain can handle threading. Dose this code look reasonable. Regards, Jeff using System; using System.Diagnostics; using System.IO; using System.Threading;
2
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to...
5
Reika
by: Reika | last post by:
Hello, I need help understanding some things in programming. I'm taking a high school level programming course, however my teacher is less than helpful in explaining or even understanding the...
5
by: Sam | last post by:
Hi, I have one table like : MyTable {field1, field2, startdate, enddate} I want to have the count of field1 between startdate and enddate, and the count of field2 where field2 = 1 between...
2
by: Tom | last post by:
My older system: Win2k, VS2005(Academic), .Net 2.0 SP1. Windows.Forms Application: Two splitter panels, a TreeView (named: "tree") in one panel populated with directory name nodes. Logic for...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.