Private Sub Adodc1_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
你直接在这里做出反应就可以了.
Case 1
If Not myrst.BOF Then
myrst.MovePrevious
else
myrst.movefirst
end if
showit
Case 2
If Not myrst.EOF Then
myrst.MoveNext
else
myrst.movelast
end if
showit
Dim mycnn As New ADODB.Connection
Dim myrst As New ADODB.Recordset
Sub showit()
For i = 0 To 3
Text1(i).Text = myrst.Fields(i).Value
Next
End Sub
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0
myrst.MoveFirst
showit
Case 1
If Not myrst.BOF Then myrst.MovePrevious: showit
Case 2
If Not myrst.EOF Then myrst.MoveNext: showit
Case 3
myrst.MoveLast: showit
Case 4
myrst.AddNew
For i = 0 To 3
myrst.Fields(i).Value = Text1(i).Text & " "
Next
myrst.Update
Case 5
For i = 0 To 3
myrst.Fields(i).Value = Text1(i).Text & " "
Next
myrst.Update
Case 6
myrst.Close
myrst.Open "select * from postzip where area='"& trim(text1(0))&"'", mycnn, adOpenKeyset, adLockOptimistic
myrst.MoveFirst
showit
Case 7
End
Set myrst = Nothing
Set mycnn = Nothing
End Select
End Sub
Private Sub Form_Load()
mycnn.Open "Provider=MicroSoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\postzip.mdb"
myrst.Open "select * from postzip ", mycnn, adOpenKeyset, adLockOptimistic
For i = 0 To 7
Command1(i).Caption = Choose(i + 1, "top", "prev", "next", "last", "new", "edit", "serch", "exit")
Next
Private Sub Adodc1_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
Label1.Caption = Adodc1.Recordset.AbsolutePosition
End Sub
Private Sub Command1_Click()
Call Adodc1.Recordset.MoveFirst
End Sub
Private Sub Command2_Click()
Call Adodc1.Recordset.MovePrevious
End Sub
Private Sub Command3_Click()
Call Adodc1.Recordset.MoveNext
End Sub
Private Sub Command4_Click()
Call Adodc1.Recordset.MoveLast
End Sub
Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=test;Data Source=SERVER"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from table3"
Adodc1.Refresh
End Sub