VB+access,在查找后得到的数据,如何删除?每次都是删除了第一条
VB+access,在查找后得到的数据,如何删除?每次都是删除了第一条
|
|
|
我的查找程序:
Private Sub find_Click()
Dim rs As ADODB.Recordset
If Text1.Text Like "[A-Z]####" <> True Then
Text1.SetFocus
Text1.Text = ""
Exit Sub
End If
openDB
Set rs = New ADODB.Recordset
rs.Open "select * from jbinfo where ygbh='" & Text1.Text & " ' ", mydb1, adOpenKeyset, adLockPessimistic
' rs.find "select * from jbinfo where ygbh='" & Text1.Text & " ' ", mydb1, adSearchBackward
If rs.EOF And rs.BOF Then
Text1.SetFocus
Text1.Text = ""
MsgBox "该员工编号不存在,请重新输入!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
ygxm.Text = rs!ygxm
ygbh.Text = rs!ygbh
bm.Text = rs!bm
xb.Text = rs!xb
csny.Text = rs!csny
jg.Text = rs!jg
cjgz.Text = rs!cjgz
jrgs.Text = rs!jrgs
byxx.Text = rs!byxx
xl.Text = rs!xl
zy.Text = rs!zy
bz.Text = rs!bz
cmddel.Enabled = True
cmddel.SetFocus
End Sub
|
|
我的删除程序:
Private Sub cmddel_Click()
Dim response As Integer
response = MsgBox("确定要修改这条记录?", vbYesNo, "警告")
If response = vbNo Then Exit Sub
With rs
.Delete
.MovePrevious
If .EOF Then .MoveLast
If .BOF Then .MoveFirst
mydb1.Close
End With
display
find.SetFocus
Text1.Text = ""
End Sub