P
paul.schrum
Access 2007 developing 2003 database
DAO
I have a recordset I want to sort in ascending order of field
"localOrder" (Long). Sometimes there will be ties. In such cases I
want it to decide on ties by sorting on UrgencyID (Long). If there
are still ties, I want it to sort by "whenAssigned", which is a Date
+Time field.
I tried the following code,
Set rst = CurrentDb().OpenRecordset( _
"SELECT taskID, whenAssigned, UrgencyID, localOrder FROM
tbl_tasks " & _
"WHERE personIDassignedTo = " & myID & _
" AND statusID = 2 ", dbOpenDynaset)
rst.Sort = "localOrder, UrgencyID, whenAssigned"
Set rstPtr = rst.Clone
rstPtr.MoveFirst
My code then proceeds to iterate through the recordset using rstPtr,
expecting it to be sorted as I need it, but it does not seem to be
happening.
Previously I had tried having several intermediate recordsets, as in
rst.Sort = "whenAssigned"
set rstTime = rst.clone
rstTime.sort = "UrgencyID"
set rstUrgency = rstTime.clone
rstUrgency.sort = "localOrder"
rstPtr = rstUrgency.clone
rstPtr.moveFirst
[.close and = Nothing code elided above]
This also did not work.
How can I accomplish the kind of sort I need?
- Paul
Schrum
DAO
I have a recordset I want to sort in ascending order of field
"localOrder" (Long). Sometimes there will be ties. In such cases I
want it to decide on ties by sorting on UrgencyID (Long). If there
are still ties, I want it to sort by "whenAssigned", which is a Date
+Time field.
I tried the following code,
Set rst = CurrentDb().OpenRecordset( _
"SELECT taskID, whenAssigned, UrgencyID, localOrder FROM
tbl_tasks " & _
"WHERE personIDassignedTo = " & myID & _
" AND statusID = 2 ", dbOpenDynaset)
rst.Sort = "localOrder, UrgencyID, whenAssigned"
Set rstPtr = rst.Clone
rstPtr.MoveFirst
My code then proceeds to iterate through the recordset using rstPtr,
expecting it to be sorted as I need it, but it does not seem to be
happening.
Previously I had tried having several intermediate recordsets, as in
rst.Sort = "whenAssigned"
set rstTime = rst.clone
rstTime.sort = "UrgencyID"
set rstUrgency = rstTime.clone
rstUrgency.sort = "localOrder"
rstPtr = rstUrgency.clone
rstPtr.moveFirst
[.close and = Nothing code elided above]
This also did not work.
How can I accomplish the kind of sort I need?
- Paul
Schrum