[AccessD] sorting a list

Drew Wutka DWUTKA at marlow.com
Mon Apr 21 22:31:19 CDT 2003


There is no 'native' way to sort a collection or an array.  However, it is
much easier to sort a collection, since filling a collection allows you to
put an item before or after another.  This allows you to 'browse' the
collection, then place the new item in the right place.  With an array, you
have to 'rebuild' the array each time, to do this.  

Code wise, you can definitely sort an array, or a collection, and be done
with it.  If you go that route, why use a value list, instead of having the
combo bound to a function?

My solution would allow Jet to do the sorting for you.  Also, it isn't
creating and destroying temp tables.  It uses one table, that only gets
bigger when necessary, but remain constant otherwise.

Either way, it's going to be a pain one way or the other! <grin>

Drew

-----Original Message-----
From: Susan Harkins [mailto:harkins at iglou.com]
Sent: Monday, April 21, 2003 8:55 PM
To: accessd at databaseadvisors.com
Subject: Re: [AccessD] sorting a list 


Well, this was my thought too -- but I'm not sure you need to do all that
work Drew -- at least not for what I'm doing. The list will always change --
so I'd just be dumping the collection straight into a table -- it wouldn't
even matter if there were no objects in the collection and the collection
were empty. So, you think that would be faster than an array? I'm not sure
how to sort an array -- is there a property?

Susan H.


> If the data is already in a collection, you sure can sort it with a query.
> Build a query that pulls the data from a collection.  I posted an example
of
> how to do this before.  Here's the basics.  Build a function that
retrieves
> the data from the collection by it's index.  Then build a simple table
with
> a number field.  Build a function that retrieves the count of the
> collection.  Have 2 fields in the query, the first field is the field from
> the number field table.  Put the Collection count as the criteria (<=).
> Have that function not only return the count of the collection, but have
it
> check the size of the collection against the highest value in that table.
> If the table has less 'numbers' then the collection, add enough records
> (with consecutive numbers) to bring it up to par.  Then have the second
> field in the query return the value from the collection based on the index
> retrieved from the number table.  Then hide the first field and sort the
> second.  Whalla!
>
> Drew
>
> -----Original Message-----
> From: Susan Harkins [mailto:harkins at iglou.com]
> Sent: Monday, April 21, 2003 8:03 PM
> To: accessd at databaseadvisors.com
> Subject: Re: [AccessD] sorting a list
>
>
> Can't use a query -- I'm using a For Each to loop through a collection to
> get the list. I thought about filling a table with the list, but that
seems
> worst than sorting an array. Wonder which would be quicker?
>
> Susan H.
>
>
> > I'd say the easiest way is to switch it to a query, put the 'list' in a
> > table, and have the query sort it! <grin>
> >
> > If you must stick with a list, use split to put it into array, then dump
> it
> > into a collection (or just resort the array).  Then rebuild the string.
> Of
> > course I think this is a long way of doing things!
> >
> > Drew
> >
> > -----Original Message-----
> > From: Susan Harkins [mailto:harkins at iglou.com]
> > Sent: Monday, April 21, 2003 7:52 PM
> > To: AccessD at databaseadvisors.com
> > Subject: [AccessD] sorting a list
> >
> >
> > Anyone have an easy way to sort a list or combo control's list when
> working
> > with a Value List RowSourceType?
> >
> > Susan H.
> >
> > _______________________________________________
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> > _______________________________________________
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> >
>
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list