Reset Order Button

  • Thread starter Thread starter Fysh
  • Start date Start date
F

Fysh

About a week ago I posted and was given a good response on
how to use up and down arrows to allow someone to change
the order of training requirements. This portion works
great, but now I have to figure a way to reset the order
back to the original position in case someone wants to be
able to do this. Here is the code that I have for
changing the ordering. By chance does someone know how to
go back and loop the table and reset each order number in
order of the id number? Any thoughts would be appreciated.

Private Sub AttUp_Click()
Dim lngOrdNum As Long

With Me.frmAnomalySubform.Form.RecordsetClone
.Bookmark = Me.frmAnomalySubform.Form.Bookmark
If .AbsolutePosition < .RecordCount Then
.Edit
lngOrdNum = !Ordering - 1
!Ordering = lngOrdNum
.Update
.MovePrevious
.Edit
!Ordering = !Ordering + 1
.Update
Forms!frmSection!frmAnomalySubform.Requery

.FindFirst "Ordering = " & lngOrdNum
Me.frmAnomalySubform.Form.Bookmark = .Bookmark
Else
Beep
End If
End With
End Sub

The table is:

ANOMALYID AutoNumber
Anomaly Text
CATID Number FK
Ordering Number
Etc.
 
Are you quite confident that your "id number" (?your Autonumber) will
maintain the proper sequence? I ask because that is NOT one of the things
for which it is designed.

If you are confident, then a simple update query will modify your Order
field to match your ID field.

If you are NOT confident, you could add another field that holds
OriginalOrder. You'd still probably use an update query to modify the Order
field, but this time, to match the OriginalOrder.

JOPO

Just One Person's Opinions

Jeff Boyce
<Access MVP>
 
You are right I never really thought about that part. I
will use your second suggestion. Thanks
 
Back
Top