Sorting Order Changes from Running Macro

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I'm getting a strange result - data in a table is sorted before its read in
the VBA macro, but comes out in a different order. Anyway to maintain the
sort order?

More Details:
I read a table generated by a query into a recordset using the following code:

Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("myQuery")

The table is sorted in the "myQuery" .

Then we read the recordset one record at a time and output the record:
rst.MoveFirst
Do Until rst.EOF
Call OutputRec(dbs, rst, outTable) 'Sub that executes sql insert
statement
rst.MoveNext
Loop

The output table is NOT in the same order as input data from myQuery.

Is there any way to make Access mainatain the sort order? Maybe its me, but
its crazy that the order isn't maintained in such a simple process.

Thank you,
Mark


.



Relevant Pages

  • Re: Sort order in PocketAccess with PPC 2003_Phone edition
    ... a recordset, I believe the cursor is at the end of the recordset. ... I have a problem with the sort order when running the comman "ORDER BY" ... in a Pocket Access database. ... In a HP 6515 with PPC 2003 Phone_Edition the sort order is incorrect, ...
    (microsoft.public.pocketpc.developer)
  • Re: open recordset sort order
    ... The trick is to use an SQL query rather than the table itself in the ... recordset definition, and do the sorting in the query, e.g. ... set rst = CurrentDb.OpenRecordset ... > this sort order so I can loop through the record set based ...
    (microsoft.public.access.modulesdaovba)
  • Help
    ... Set dbs = CurrentDb ... Set rst = dbs.OpenRecordset ... The output table is NOT in the same order as input data from myQuery. ... Is there any way to make Access maintain the sort order? ...
    (microsoft.public.access.modulesdaovba)
  • Re: Loop concatenation problem
    ... Dim dbs As Database, rst As Recordset ... Set dbs = CurrentDb ...
    (microsoft.public.access.modulesdaovba)
  • Re: Access object error
    ... it the code stalls at this line with this error message: ... >>Dim dbs As Database, rst As Recordset ... >>Set dbs = CurrentDb ... >> Set rst = dbs.OpenRecordset ...
    (microsoft.public.access.modulesdaovba)