I have the following code for a delete button written in visual basics in Microsoft Access.
Private Sub Delete_Click()
If Not (Me.ComputerSubform.Form.Recordset.EOF And Me.ComputerSubform.Form.Recordset.BOF) Then
If MsgBox("Are you sure to delete?", vbYesNo) = vbYes Then
CurrentDb.Execute "DELETE FROM Computer " & _
" WHERE PCSN=" & Me.ComputerSubform.Form.Recordset.Fields("PCSN")
Me.ComputerSubform.Form.Requery
End If
End If
End Sub
The first time it words fine. But when I try to delete another record I will encounter "Run time error 3021- no current record". I could not understand as the code look fines to me and there is data available. I would appreciate any help. Thanks!
P.S. I am sorry I can't post my table as it contain alot of confidential data.