|
- Private Sub Cmd_删除产品_Click()
- Dim i As Integer
- Dim Stemp As String
- Dim rs As ADODB.Recordset
- Dim Rsql As String
- Set rs = New ADODB.Recordset
- Stemp = "Select * From 物品资料表"
- rs.Open Stemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
- If rs.RecordCount < 1 Then
- Exit Sub
- End If
- rs.MoveFirst
- For i = 1 To rs.RecordCount
- If rs("产品代码") = Me![Frm_物品资料输入子窗体]![产品代码] Then
- MsgBox rs("产品代码")
- rs.Delete 1
- MsgBox "产品代码:" & Me![产品代码] & "的资料已经删除完成!", vbOKOnly, "删除完成"
- Exit For
- Else
- rs.MoveNext
- End If
- Next i
- Me![Frm_物品资料输入子窗体].Requery
- Set rs = Nothing
- Exit_删除产品:
- Set rs = Nothing
- Exit Sub
- Err_删除产品:
- MsgBox Err.Description
- Resume Exit_删除产品
- End Sub
复制代码 建议直接用SQL动作查询,快又准,
就算你用ado也没有必要循环,直接在stemp上设定条件
|
|