如题。
程序各参数分别为:
f 子窗体;
idN 自动编号字段名;
orderN 排序字段名称;
key 'UP'上移,'down'下移
Private Sub MoveRecord(f As Form, idN As String, orderN As String, key As String)
Dim i As Integer
Dim tmp0 As Long, tmp1 As Long, flag As Boolean, count As Integer, mark As Integer
Dim re As DAO.Recordset
Set re = f.Recordset
With re
mark = .Fields(idN)
tmp0 = .Fields(orderN)
Select Case key
Case "up"
.MovePrevious
flag = .BOF
Case "down"
.MoveNext
flag = .EOF
End Select
If flag = False Then
.Edit: tmp1 = .Fields(orderN): .Fields(orderN) = tmp0: .Update
Select Case key
Case "up"
.MoveNext
Case "down"
.MovePrevious
End Select
.Edit: .Fields(orderN) = tmp1: .Update
f.Requery
.FindNext idN & "=" & mark
If .AbsolutePosition < 0 Then
f.Requery
.FindNext idN & "=" & mark
End If
Else
Select Case key
Case "up"
.MoveNext
Case "down"
.MovePrevious
End Select
End If
End With
End Sub
[此贴子已经被作者于2005-1-27 17:28:31编辑过]
|