|
Private Sub 删除资产_Click()
On Error GoTo err_删除资产_click
Dim stemp As String
Dim i As Integer
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
stemp = "select*from 固定资产"
rs.Open stemp, CurrentProject.Connection, adOpenKeyset, adLockBatchOptimistic
If rs.RecordCount < 1 Then
Exit Sub
End If
rs.MoveFirst
For i = 1 To rs.RecordCount
If rs("资产编号") = Me![固定资产 子窗体]![资产编号] Then
rs.Delete 1
Exit For
Else
rs.MoveNext
End If
Next i
MsgBox "资产:" & Me![资产编号] & "的资料已经删除完成", vbOKOnly, "删除完成"
Me![固定资产 子窗体].Requery
Set rs = Nothing
exit_删除资产_click:
Set rs = Nothing
Exit Sub
err_删除资产_click:
MsgBox Err.Description
Resume exit_删除资产_click
End Sub
编程在运行上面程序的时候,直接跳出“删除完成”的对话框,但子报表中的数据并没有删除,不知道是不是for...next语句的原因,请高手指教 |
|