473,549 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

messing around with the item ordering of a Collection - the Controls one, specifically

hey guys,

Question about the internal workings of Access. How are controls added
in the Form.Controls collection? I mean, in which order?
the order place them on the form? is there a way to re-arrange them as
i please? My solution is to remove the objects from the Form.Controls
collection, place them in a tmpCollection, arrange tmpCollection as I
please, and then re-add them back into the Form.Controls collection.
thanks
Btw, is there any tools that let you comment blocks of code at a time?
i'm tired of doing it by hand?

-><-
Ghost In My Shell

Nov 13 '05 #1
9 1617
I don't know about the first question, but may be able to help with the
second one. At least in Access 2003, in the code editor go to View|Toolbars
and select the Edit toolbar. It will have two buttons for Comment and
Uncomment Block. Highlight the desired code and click the button.

--
Wayne Morgan
MS Access MVP
<Pr**********@g mail.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
hey guys,

Question about the internal workings of Access. How are controls added
in the Form.Controls collection? I mean, in which order?
the order place them on the form? is there a way to re-arrange them as
i please? My solution is to remove the objects from the Form.Controls
collection, place them in a tmpCollection, arrange tmpCollection as I
please, and then re-add them back into the Form.Controls collection.
thanks
Btw, is there any tools that let you comment blocks of code at a time?
i'm tired of doing it by hand?

-><-
Ghost In My Shell

Nov 13 '05 #2
Pr**********@gm ail.com wrote:
hey guys,

Question about the internal workings of Access. How are controls added
in the Form.Controls collection? I mean, in which order?
the order place them on the form? is there a way to re-arrange them as
i please? My solution is to remove the objects from the Form.Controls
collection, place them in a tmpCollection, arrange tmpCollection as I
please, and then re-add them back into the Form.Controls collection.
thanks
Btw, is there any tools that let you comment blocks of code at a time?
i'm tired of doing it by hand?


I sense a certain relation between these two issues. What are you doing?
I have been fairly busy creating and manipulating controls in a form.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #3
nope, no relation between the two.

i wish i had copied the .adp file to my usb stick, so i could show
you...
I sure would love to have a pier review of my code... Hmm... I'll post
it on monday.

Ok, here's the basic idea.
I'm the Junior Code Monkey[tm] at work. I'm a lazy fuck, in the Larry
Wall/Perl lazy fuck way :) .So, instead of doing something like
With rs
.. AddNew
..Fields("ID") = textbox.Value
<blahblahblah >
..Update
End With

i did this (Thanks go out to cubert in EFnet #VisualBasic):

For each tmpControl in Form.Controls

if( typeof tmpControl is label or typeof tmpControl is label ) then
<code here>
elseif( typeof tmpControl is TextBox ) then
rs.Fields(tmpCo ntrol.Name) = tmpControl.Valu e
elseif( typeof tmpControl is ComboBox ) then
' column 0 is the id field in my controls
rs.Fields(tmpCo ntrol.Name) = tmpControl.Colu mn( 0, tmpControl.List Inex)
elseif( typeof tmpControl is commandbutton ) then
<code here>

.....
else
' i fucked up, somewhere

end if

rs.Update

I got yelled at :`(

Head Code Monkey wants me to do it this way

With rs
..AddNew
..Fields![ID] = frmMyForm.Contr ols("ID").Value
..Fields![Name] = frmMyForm.Contr ols("Name").Val ue
<etc, etc, for all controls of the form>
..Update
End with

he keeps insisting that his way is the correct way of doing things and
it gives you complete control of your code and, "dog gone is, i do it
this way so, so will you!"

I think his way is stupid, because you'll have to mess with the code
each time you add a control.

bah, i think he's a fucking moron. I think my way rules, because i'll
never have to mess with the code ever again in order to write a record
into the db. What do you think?

Nov 13 '05 #4
Pr**********@gm ail.com wrote:

Ump! I'm not a native speaker!
I sure would love to have a pier review of my code... Hmm... I'll post
it on monday.
Is that "peer review"? I certainly don't want to leave the impression of
over-correcting, just making sure I understand.
I'm the Junior Code Monkey[tm] at work. I'm a lazy fuck, in the Larry
Wall/Perl lazy fuck way :)
Lazy people have to be inventive such as to circumvent the sweat labor!
With rs
. AddNew
.Fields("ID") = textbox.Value
<blahblahblah >
.Update
End With
Looks to me as a manual lot of code in an unbound form to do what a
bound form can do. Is that it?
For each tmpControl in Form.Controls

if( typeof tmpControl is label or typeof tmpControl is label ) then
elseif( typeof tmpControl is TextBox ) then
rs.Fields(tmpCo ntrol.Name) = tmpControl.Valu e
What is the double test for? I see no difference

What about a

Select Case tmpControl.cont roltype
case actextbox
case accombobox, aclistbox
case else
end select

?
I got yelled at :`(

Head Code Monkey wants me to do it this way

With rs
.AddNew
.Fields![ID] = frmMyForm.Contr ols("ID").Value
.Fields![Name] = frmMyForm.Contr ols("Name").Val ue
<etc, etc, for all controls of the form>
.Update
End with
Is this code local to the form, or in some module? Addressing the
controls through the Controls collection always looks a bit overdone to me.
he keeps insisting that his way is the correct way of doing things and
it gives you complete control of your code and, "dog gone is, i do it
this way so, so will you!"
I fail to see that as "the correct way". It depends.
I think his way is stupid, because you'll have to mess with the code
each time you add a control.
If you get payed for it... of course you're right, double work lures. I
like the "open approach", but it shall not bother me with extra bookkeeping.
bah, i think he's a fucking moron. I think my way rules, because i'll
never have to mess with the code ever again in order to write a record
into the db. What do you think?


Your expression is, as Spock might say, emotional; but I agree with your
point. I don't see yet why this isn't handled in the form itself, that
is simpler. You don't have to write code at all to have values enter the
table.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #5

Bas Cost Budde wrote:
Is that "peer review"? I certainly don't want to leave the impression of over-correcting, just making sure I understand. Bones... I... am... running... out... of... greek... coffee...
must... refill ... intraveinous... coffee... sollution...
(yeah, you're correct. i got the SpellingMistake Desease :) )
Lazy people have to be inventive such as to circumvent the sweat labor!
With rs
. AddNew
.Fields("ID") = textbox.Value
<blahblahblah >
.Update
End With
Looks to me as a manual lot of code in an unbound form to do what a
bound form can do. Is that it?


yup. Head Code Monkey[tm] favors lots of manual labor like that.

What is the double test for? I see no difference

What about a

Select Case tmpControl.cont roltype
case actextbox
case accombobox, aclistbox
case else
end select
eh, it's the same deal. the difference is that before you mentioned the
..ControlType property, I never new it existed. :)
The reason I'm using multiple IFs is that i'm doing some manipulation
of some labels to let my users feel all nice about themselves >:) ("YOU
HAVE ENTERED A NEW RECORD!")
?
I got yelled at :`(

Head Code Monkey wants me to do it this way

With rs
.AddNew
.Fields![ID] = frmMyForm.Contr ols("ID").Value
.Fields![Name] = frmMyForm.Contr ols("Name").Val ue
<etc, etc, for all controls of the form>
.Update
End with
Is this code local to the form, or in some module? Addressing the
controls through the Controls collection always looks a bit overdone

to me.
my code is local to the form. i got a module (which i should turn into
a class some time in the future) but only things that more than 1 form
uses go there (like my emtpyRowSources ( byref tmpForm as Form) )

By the way, what's wrong with passing forms and objects by reference?
Head Code Monkey insists its the wrong way to do things and that's it's
memory intensive. I'm like "Chill man, I'm passing a pointer, not the
whole object"
I fail to see that as "the correct way". It depends. Yeah, i know. in programming there is no "correct way"...
Your expression is, as Spock might say, emotional; but I agree with your point. I don't see yet why this isn't handled in the form itself, that is simpler. You don't have to write code at all to have values enter the table.

Boss loves unbound forms. He insists we use unbound forms. if he let me
use bound forms, this project would be over 2 months ago. that's why i
had to learn how to manipulate a form by hand. As for emotional, heh,
I'm Greek ^_^

Thanks,
George

Nov 13 '05 #6
Pr**********@gm ail.com wrote:
(yeah, you're correct. i got the SpellingMistake Desease :) )
I like that :-)
Looks to me as a manual lot of code in an unbound form to do what a
bound form can do. Is that it?


yup. Head Code Monkey[tm] favors lots of manual labor like that.


Can't you find another tree to work then? Sheesh.

Using unbound forms, so bypassing all mechanisms that make Access so
slow and large; well, I started a company of my own for such reasoning.
eh, it's the same deal. the difference is that before you mentioned the
.ControlType property, I never new it existed. :)
Welcome to Property country.
The reason I'm using multiple IFs is that i'm doing some manipulation
of some labels to let my users feel all nice about themselves >:) ("YOU
HAVE ENTERED A NEW RECORD!")
I'll take that. Humans (counting me as one :-) ) don't have to
understand everything.
You can do whatever you want to separate labels inside the Case acLabel.
I guess you will do that.
my code is local to the form. i got a module (which i should turn into
a class some time in the future) but only things that more than 1 form
uses go there (like my emtpyRowSources ( byref tmpForm as Form) )
Does it have to become a Class? Classes form objects you can create; to
have just a function repository does not require class status. It would
even hamper certain simple things. (Don't show this message to the Head
Monkey then.)
By the way, what's wrong with passing forms and objects by reference?
Strong-typed question. In itself there is nothing wrong with passing
forms by reference. It is the only possible way, accidentally.
It *would* be possible to pass an object by 'value' (whatever that may
mean) but man, that is memory intensive.
Head Code Monkey insists its the wrong way to do things and that's it's
memory intensive. I'm like "Chill man, I'm passing a pointer, not the
whole object"
Exactly. Just four bytes. Intensive to his memory, maybe.
Boss loves unbound forms. He insists we use unbound forms. if he let me
use bound forms, this project would be over 2 months ago. that's why i
had to learn how to manipulate a form by hand.
The other thing you said about control order, what is that supposed to
bring? Because that part of the question I haven't addressed yet, and I
think I can contribute.
As for emotional, heh, I'm Greek ^_^


<VBG> I am musician, I play folk music from the eastern Europe region. I
can't understand all those languages but I speak their music perfectly.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #7
<Pr**********@g mail.com> wrote
Boss loves unbound forms. He insists
we use unbound forms. if he let me use
bound forms, this project would be over
2 months ago.
That'd be OK if he were paying for the work... but if I found a contractor
or vendor with that attitude, I'd ask for my money back, and then fire them.
that's why i had to learn how to manipu-
late a form by hand. As for emotional, heh,
I'm Greek ^_^


No particular fun in that, but it does give you some "job security" as
everything will take longer to complete than using bound forms.

Larry Linson
Microsoft Access MVP
Nov 13 '05 #8
> Can't you find another tree to work then? Sheesh.
I'm trying man, i'm trying. By the way, i'm an EU citizen. so, you
know, i can work in holland :) *hint*hint*
Welcome to Property country. I'm here to stay :)
Does it have to become a Class? Classes form objects you can create; to have just a function repository does not require class status. It would even hamper certain simple things. (Don't show this message to the Head Monkey then.) I need to read more on Access Classes and how the differ from VBA
classes
Strong-typed question. In itself there is nothing wrong with passing
forms by reference. It is the only possible way, accidentally.
It *would* be possible to pass an object by 'value' (whatever that may mean) but man, that is memory intensive. What I was really asking was, does access have a problem with its
memory manager? is it dangerous passing pointers in access? are there
any bugs in the way access handles pointers (like pointers becomming
corrupt after a while)? any limitations?

Head Code Monkey insists that the way to go is to pass the name of the
object you want to refer to, and he says so with a passion, so that
makes me wonder, if access is fucking up.

The other thing you said about control order, what is that supposed to bring? Because that part of the question I haven't addressed yet, and I think I can contribute.

i was trying to associate the controls in the forms with the fields
in the database. I had no clue about the Field.Colection (Control.Name)=
Control.Value trick. thought i should have thought about it, because i
was Clueless[tm] and the "Access 2002" and "VBA Developer" books I
ordered from amazon have not arrived yet (grrr >:( ).
so, instead of depending on the name of the controls and the name of
the fields to do the mapping/association, i was using the ordering of
the controls, hopeing that both .Fields and .Controls would be ordered
the same way, internaly. The problem was that they didn't. What
intrigued me though, was the fact that the order of the items inside
the collection was the same, each time i opened the form. That got me
thinking that the collection gets preserved in memory or the .adp file,
somewhere. so, theoritically, it should have an index stored in the
file, which i could mess with, and order the Controls in the same way
the fields in my database were ordered. it was the lame thing to do.
George Marselis

Nov 13 '05 #9
George Marselis wrote:
I'm trying man, i'm trying. By the way, i'm an EU citizen. so, you
know, i can work in holland :) *hint*hint*
If the work ever grows over my head, you'll be invited :-)
I need to read more on Access Classes and how the differ from VBA
classes
%-| VBA is the Basic dialect in Access, I can't see what you're saying here.
What I was really asking was, does access have a problem with its
memory manager?
Yes. Setting a database object variable but not setting it to Nothing
when you're done is known to produce a memory leak quite reliably.

Of course you cannot do anything about this but programming correctly :-)
is it dangerous passing pointers in access?
You don't see it. It is impossible, as opposite to languages as C, to
change the pointer. I mean, you cannot assign it a memory address, only
a variable address.
are there
any bugs in the way access handles pointers (like pointers becomming
corrupt after a while)?
The Database is the only one that really ever bugged me.
any limitations?
NTIK
Head Code Monkey insists that the way to go is to pass the name of the
object you want to refer to, and he says so with a passion, so that
makes me wonder, if access is fucking up.
mmm... if you put the name of the object in the call, the interpreter
*will* pass it as pointer. So maybe all you need is a little diplomacy.
i was trying to associate the controls in the forms with the fields
in the database. I had no clue about the Field.Colection (Control.Name)=
Control.Value trick. thought i should have thought about it, because i
was Clueless[tm] and the "Access 2002" and "VBA Developer" books I
ordered from amazon have not arrived yet (grrr >:( ).
So you use A2K2. In case I forgot. I have A97.
so, instead of depending on the name of the controls and the name of
the fields to do the mapping/association, i was using the ordering of
the controls, hopeing that both .Fields and .Controls would be ordered
the same way, internaly. The problem was that they didn't.
It's a safe bet they don't.
intrigued me though, was the fact that the order of the items inside
the collection was the same, each time i opened the form.
Oh yes, controls do have an order. The order in which they get inserted
is a good candidate, I never really investigated.
Controls that can receive focus have a TabOrder property which
indicates, surprise, the order in which they will receive focus when the
user presses the Tab key.
somewhere. so, theoritically, it should have an index stored in the
file, which i could mess with, and order the Controls in the same way
the fields in my database were ordered.


mmm Name resolution is slightly better. You could even put the data
source name in the Tag property of the control, leaving its name free.
Sometimes you have two controls on one field, effectively defying the
name-source link. With bound forms, that's where the Controlsource
property comes in.
--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #10

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

Similar topics

3
2523
by: Marc L'Ecuyer | last post by:
Hi, I have a collection class derived from CollectionBase. This collection can add items of my class MyItem. In my class MyItem, I have a Selected property. When this property is set to true, I have to set this property to false for all other items in the collection (only 1 item can be selected). How can I do that? Thanks
7
2501
by: Grant Schenck | last post by:
Hello, I have a ListBox control on a form. I add members of a class to the Items collection. They show up and I can select them. The text shown is from my classes ToString override. Now, later on I need to update this item. I find it in the Items collection and update a member used by the ToString member function. However, the text...
5
5954
by: GaryB | last post by:
The datagrid.items collection only appears to have data rows in it. for Instance... dim myItem ad dataGridItem myItem = myGrid.Items(0) returns the first data row of data. How can I access the Headertext and footer text? The docs say ... " A DataGridItem represents an item (row) in a DataGrid control, such as a
4
3992
by: juststarter | last post by:
Hello, I have an aspx file where i've put a placeholder element. On load (page_load) i create dynamically an html table which contains a checkbox and a radiobuttonlist in each tablerow . The radiobuttonlist contains two items (yes,no). Both the checkboxes and the radiobuttonlist are NOT autopostbacked ( .autopostback = false). When i press...
9
2684
by: Max Weebler | last post by:
Hi, I have a datagrid built that has an alternating item style that sets the backcolor and ForeColor of its rows. I have 4 template columns. One of them has a LinkButton embedded in it to perform updates. All the styles that are set are being followed by all templated columns with the exception for the update column. The update column...
18
4715
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the class where only the "searched" property has a value. I expected to get the index into the arraylist where I could then get the entire class...
23
11269
by: illegal.prime | last post by:
Hi all, is there a key value collection in .Net that maintains the ordering in which I add items. I'm finding that I'm creating a number of classes that contain a name and then some object. I would prefer just to use some collection that maintains the ordering in which I add things (like ArrayList), but that maps a key to a value. I...
5
2663
by: =?Utf-8?B?VG9t?= | last post by:
Cannot not seem to make any sense of the order that my key/values end up in when added to the Hashtable...ideally, I would like to be able to sort the keys/values...but not thinking it is possible. For those who are sure going to ask why I am asking this....I use the Hashtable for conveniently cross-referencing pairs of information...and I...
10
62814
by: Frank Rizzo | last post by:
How do I get the first item that was added to the Dictionary object. I've tried myDictionary, but it's not supported? Regards
0
7520
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7450
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7720
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7470
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1941
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.