I have a table with a field called Priority. Each record in the table has a priority except for the completed ones.
What I want is to be able to check mark my Completed box on my form and have it set that record to a priority of 0 and to reorder all of the other records' priorities to fill in the gap.
i.e.
Red 1
Blue 2
Green 3
-->if I complete Blue the table should look like this.
Red 1
Blue 0
Green 2
I know to build an expression in on click for that box but I can't get the records to reorder themselves. I've tried using someone else's code that does something like this but it doesn't quite work. Here's what I have so far:
Any help would be appreciated. I'm up for scrapping this code and going a different route if you have any suggestions.
What I want is to be able to check mark my Completed box on my form and have it set that record to a priority of 0 and to reorder all of the other records' priorities to fill in the gap.
i.e.
Red 1
Blue 2
Green 3
-->if I complete Blue the table should look like this.
Red 1
Blue 0
Green 2
I know to build an expression in on click for that box but I can't get the records to reorder themselves. I've tried using someone else's code that does something like this but it doesn't quite work. Here's what I have so far:
Code:
intCurrentPriority = 1
[Forms]![Printing Data Input Form]![Priority] = 0
With rst
.ActiveConnection = CurrentProject.Connection
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open "SELECT * from [Printing Data Input] ORDER BY Priority"
If (.RecordCount > 0) Then
.MoveFirst
Do
If (!Priority >= 1 And !Priority <> intCurrentPriority) Then
!Priority = intCurrentPriority
.Update
.MoveLast
End If
intCurrentPriority = intCurrentPriority + 1
.MoveNext
Loop While Not .EOF
End If
.Close
End With
Set rst = Nothing
Set cnxn = Nothing
Exit_Completed_Click:
Exit Sub
Err_Completed_Click:
MsgBox Err.Description
End Sub
Any help would be appreciated. I'm up for scrapping this code and going a different route if you have any suggestions.