user692495
user692495

Reputation: 69

"operation is not allowed when the object is open"

When I am trying to execute the program I am getting an error like "operation is not allowed when the object is open". I'm using vb 6.0 and microsoft access database. here is the source code

Private Sub cmdDelete_Click()
        dtaOverhead.Recordset.Open "Delete from variable where SWACTFM= " & txtEntry(0).Text & " And SWBUDACT = " & txtEntry(1).Text & " And SWREMFM = '" & txtEntry(12).Text & "' And SWACTRAW = " & txtEntry(2).Text & " And SWBUDRAW = " & txtEntry(3).Text & " And SWREMRAW = '" & txtEntry(13).Text & "' And SWACTWHS = " & txtEntry(4).Text & " And SWBUDWHS = " & txtEntry(5).Text & " And SWREMWHS = '" & txtEntry(14).Text & "' And SWACTLAB = " & txtEntry(6).Text & " And SWBUDLAB = " & txtEntry(7).Text & " And SWREMLAB = '" & txtEntry(15).Text & "' And SWACTWORK = " & txtEntry(8).Text & " And SWBUDWORK = " & txtEntry(9).Text & " And SWREMWORK = '" & txtEntry(16).Text & "' And SWACTTOTAL = " & txtEntry(10).Text & " And SWBUDTOTAL = " & txtEntry(11).Text & " And SWREMTOTAL = '" & txtEntry(17).Text & "'"
        MsgBox "Record deleted successfully !", vbInformation, "Deletion Successful"
        Call Filllist
        Call clearall
        cmdSave.Caption = "&Save"

End Sub

Upvotes: 2

Views: 17423

Answers (1)

Bob77
Bob77

Reputation: 13267

You can't open a Recordset twice (er, without closing it in between anyway).

A DELETE would normally be done using Connection.Execute or Command.Execute, not Recordset.Open.

Upvotes: 4

Related Questions