怪事...必出於在下才疏學淺...幫幫忙..
下面的程式刪除方面有問題:程式一啟動後,馬上刪除一筆資料,指標居然向後退兩次!?也就是說,程式一啟動後,啥麼都不要動,馬上刪除一筆資料,然後按下前一筆,居然有資料!奇怪了...只有一啟動後馬上刪除會這個樣子耶...
前輩們告訴我為啥麼好ㄇ...
Option Explicit
Public cn As New ADODB.Connection
Public rs As New ADODB.Recordset
Private Sub add_Click()
rs.AddNew
End Sub
Private Sub cancel_Click()
rs.CancelUpdate
End Sub
Private Sub Command1_Click()
rs.MoveFirst
End Sub
Private Sub Command2_Click()
With rs
.MovePrevious
If .BOF Then .MoveFirst
End With
End Sub
Private Sub Command3_Click()
With rs
.MoveNext
If .EOF Then .MoveLast
End With
End Sub
Private Sub Command4_Click()
rs.MoveLast
End Sub
Private Sub delete_Click()
With rs
.delete
.MoveNext
If .EOF Then .MoveLast
End With
End Sub
Private Sub Exit_Click()
End
End Sub
Private Sub Form_Load()
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\WINDOWS\Desktop\db1.mdb;Persist Security Info=False"
cn.Open
rs.Open "tb1", cn, adOpenStatic, adLockOptimistic, adCmdTable
Set Text1.DataSource = rs
Set Text2.DataSource = rs
Text1.DataField = "id"
Text2.DataField = "name"
End Sub
Private Sub save_Click()
rs.Update
End Sub