469,900 Members | 1,714 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,900 developers. It's quick & easy.

Sorting a recordset?

MLH
In the code snippet below, MyMovies is a table of movie names.
First field is a unique long integer ID. Second field is text string
containing movie name. The second field's Indexed Property
setting is Yes (no duplicates).

I would like to open the dynaset sorted on the first field rather
than on the second field. First field is [MovieID]. Second field is
[MovieName]. Anyone know how to structure the DAO so the
table is opened sorted on the first field? Or, how to re-sort it after
the Recordset is already opened?

Dim MyDB As Database, MySet As Recordset
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MySet = MyDB.OpenRecordset("MyMovies", DB_OPEN_DYNASET)
MySet.MoveLast
...
Nov 13 '05 #1
3 11367
"MLH" <CR**@NorthState.net> wrote in message
news:07********************************@4ax.com...
In the code snippet below, MyMovies is a table of movie names.
First field is a unique long integer ID. Second field is text string
containing movie name. The second field's Indexed Property
setting is Yes (no duplicates).

I would like to open the dynaset sorted on the first field rather
than on the second field. First field is [MovieID]. Second field is
[MovieName]. Anyone know how to structure the DAO so the
table is opened sorted on the first field? Or, how to re-sort it after
the Recordset is already opened?

Dim MyDB As Database, MySet As Recordset
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MySet = MyDB.OpenRecordset("MyMovies", DB_OPEN_DYNASET)
MySet.MoveLast


Base the RecordSet on a SQL Statement instead if the raw table.

Dim MyDB As Database, MySet As Recordset
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MySet = MyDB.OpenRecordset("SELECT * FROM MyMovies ORDER BY MovieID",
DB_OPEN_DYNASET)
MySet.MoveLast

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #2
MLH
Yes, I had considered that. But I wanted to do it at the table
level within DAO, if it could be done. A workaround that
accomplished the objective was to switch the order of the
two fields. Making [MovieName] the first field and making
its Indexed Property setting Yes No Duplicates did the
trick. But, do you know if there is a way to sort the
RecordSet after opening with DAO?

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx

On Tue, 30 Nov 2004 21:35:21 -0600, "Rick Brandt"
<ri*********@hotmail.com> wrote:
"MLH" <CR**@NorthState.net> wrote in message
news:07********************************@4ax.com.. .
In the code snippet below, MyMovies is a table of movie names.
First field is a unique long integer ID. Second field is text string
containing movie name. The second field's Indexed Property
setting is Yes (no duplicates).

I would like to open the dynaset sorted on the first field rather
than on the second field. First field is [MovieID]. Second field is
[MovieName]. Anyone know how to structure the DAO so the
table is opened sorted on the first field? Or, how to re-sort it after
the Recordset is already opened?

Dim MyDB As Database, MySet As Recordset
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MySet = MyDB.OpenRecordset("MyMovies", DB_OPEN_DYNASET)
MySet.MoveLast


Base the RecordSet on a SQL Statement instead if the raw table.

Dim MyDB As Database, MySet As Recordset
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MySet = MyDB.OpenRecordset("SELECT * FROM MyMovies ORDER BY MovieID",
DB_OPEN_DYNASET)
MySet.MoveLast


Nov 13 '05 #3
"MLH" <CR**@NorthState.net> wrote in message
news:bl********************************@4ax.com...
Yes, I had considered that. But I wanted to do it at the table
level within DAO, [SNIP]


Please explain this. You do realize that when you open the RecordSet
directly on the tablename Jet is actually doing a "SELECT * FROM TabelName"
in the background don't you? By explicitly using a SQL statement yourself
you are simply adding the ability to filter and sort.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Travis Pupkin | last post: by
12 posts views Thread by CJM | last post: by
22 posts views Thread by Gerry Abbott | last post: by
7 posts views Thread by Geert Elias | last post: by
1 post views Thread by Marc | last post: by
reply views Thread by stainless | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.