Hi
OK, OK, is it April Fool's day already?
I have an ADODB RS based form. Amongst others it has :-
1. A unique autonum column "Unique_No"
2. "Field_Selected" column
3. 'List_Order' column
4. It has a .sort of "[Field_Selected] DESC,[TBL1.List_Order]"
. (Note: TBL1. table alias is because there is a JOIN).
List Order is, unsurprisingly, the order in which the records are displayed to the user
Users can select/de-select the [field_selected] col. When they do so I re-order the List_Order col. I do this by zooming down the RS and by adding 1 to the list order count. Or so I planned....
Because[List_Order] is used in the .Sort, the Index gets confused because when, say, Rec_A gets a new List_Order=2, Rec_D might already have a List_Order=2. .. upshot is that records get skipped and all the numbering gets out of sequence.
So... I first loop down the RS and set all the List_orders to 0 - (minus) their own value. This way they will not clash when re-numbered.
All is fine. BUT I then loop down them again to increment their List_Orders with + (positive) nos...
For some infuriating reason, the second do-loop just continually goes around the [Field_Selected]=True records (which are all now at the top) So the .movenext just goes back to the beginning..... I guess when the current record gets it's new list_order, the RS automatically resorts itself and the cursor goes to a position further back?
Any ideas anyone please? Thnx.
OK, OK, is it April Fool's day already?
I have an ADODB RS based form. Amongst others it has :-
1. A unique autonum column "Unique_No"
2. "Field_Selected" column
3. 'List_Order' column
4. It has a .sort of "[Field_Selected] DESC,[TBL1.List_Order]"
. (Note: TBL1. table alias is because there is a JOIN).
List Order is, unsurprisingly, the order in which the records are displayed to the user
Users can select/de-select the [field_selected] col. When they do so I re-order the List_Order col. I do this by zooming down the RS and by adding 1 to the list order count. Or so I planned....
Because[List_Order] is used in the .Sort, the Index gets confused because when, say, Rec_A gets a new List_Order=2, Rec_D might already have a List_Order=2. .. upshot is that records get skipped and all the numbering gets out of sequence.
So... I first loop down the RS and set all the List_orders to 0 - (minus) their own value. This way they will not clash when re-numbered.
Code:
Set Prc_RstAdo = me.form.recordset.Clone
With Prc_RstADO_A
.Sort = "" 'remove the sort
.MoveFirst
Do Until .EOF
![TBL1.List_Order] = (0 - ![TBL1.List_Order])
.Update
.MoveNext
Loop
Code:
Sort_Field = "[Field_Selected] DESC,[TBL1.List_Order] DESC" 'Note-Sorted on DESC here cos' of minus nos
.Sort = Sort_Field 're-apply the sort
.MoveFirst
Do Until .EOF
New_List_Order = New_list_order + 1
![TBL1.List_Order] = New_list_order
.Update
.MoveNext
Loop
End With
For some infuriating reason, the second do-loop just continually goes around the [Field_Selected]=True records (which are all now at the top) So the .movenext just goes back to the beginning..... I guess when the current record gets it's new list_order, the RS automatically resorts itself and the cursor goes to a position further back?
Any ideas anyone please? Thnx.
Last edited: