Private Sub btnMoveUp_Click()
'If the SortOrder is 1, then do nothing
If Me.SortOrder = 1 Then
MsgBox ("Can't move question up if it is already on top of the list.")
Else
Dim RecNum As Integer 'Unique ID of the record
Dim MySort As Integer 'Current SortOrder for the question selected
Dim Audit_ID As Long
Dim Question_ID As Integer
Dim OtherQSort As Integer 'The SortOrder for the other question that will be moved
RecNum = Me.ID
Audit_ID = Me.Audit_ID
Question_ID = Me.Question_ID
MySort = Me.SortOrder
MySort = MySort - 1
OtherQSort = Me.SortOrder
'First, move the SortOrder DOWN by minus 1 for the question above the selected question
strSQL = "UPDATE dbo_jntbl_AuditToQuestion SET SortOrder= " & OtherQSort & " WHERE Audit_ID= " & Audit_ID & " AND SortOrder = " & MySort & ""
CurrentDb.Execute strSQL, dbFailOnError Or dbSeeChanges
'Then move the SortOrder UP by plus 1 for the selected question
strSQL = "UPDATE dbo_jntbl_AuditToQuestion SET SortOrder = " & MySort & " WHERE Audit_ID= " & Audit_ID & " AND Question_ID = " & Question_ID & ""
CurrentDb.Execute strSQL, dbFailOnError Or dbSeeChanges
'Refresh the list
Me.Requery
'Keep the focus on the same record after requery
Set rstClone = Me.RecordsetClone
With rstClone
.FindFirst "ID=" & RecNum
If Not .NoMatch Then
Me.Bookmark = .Bookmark
Me.btnMoveUp.SetFocus
End If
.Close
End With
Set rstClone = Nothing
End If
End Sub