做了一个“向下”按钮,希望点击一下就可以显示下一条,可这段代码却不能实现这一功能!
Private Sub cmd_next_Click()
Dim rst As New ADODB.Recordset
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient
rst.CursorType = adOpenStatic
rst.LockType = adLockOptimistic
rst.Open "Gy_ExtendProcess", cnn, , , adCmdTable
If rst.AbsolutePosition <> adPosBOF Then
rst.MoveLast
Text1.Text = rst.Fields(1).Value
End If
End Sub为什么text1显示不出表里的数据。AbsolutePosition的值总是为-2,为什么?
Private Sub cmd_next_Click()
Dim rst As New ADODB.Recordset
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseClient
rst.CursorType = adOpenStatic
rst.LockType = adLockOptimistic
rst.Open "Gy_ExtendProcess", cnn, , , adCmdTable
If rst.AbsolutePosition <> adPosBOF Then
rst.MoveLast
Text1.Text = rst.Fields(1).Value
End If
End Sub为什么text1显示不出表里的数据。AbsolutePosition的值总是为-2,为什么?
最后写一个查询显示语句rs.movenext这样子就可以了
private rst As New ADODB.RecordsetPrivate Sub form_load()
rst.CursorLocation = adUseClient
rst.CursorType = adOpenStatic
rst.LockType = adLockOptimistic
rst.Open "Gy_ExtendProcess", cnn, , , adCmdTable
End subprivate sub command1_click()
If not rst.eof Then
Text1.Text = rst.Fields(1).Value
rst.MoveLast
endif
end sub