ms-access - "operation is not allowed when the object is open"

标签 ms-access vb6

当我尝试执行程序时,出现“对象打开时不允许操作”之类的错误。我正在使用 vb 6.0 和 microsoft access 数据库。这是源代码

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

最佳答案

您不能两次打开记录集(呃,中间不关闭它)。

DELETE 通常使用 Connection.ExecuteCommand.Execute 完成,而不是 Recordset.Open .

关于ms-access - "operation is not allowed when the object is open",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10206050/

相关文章:

ms-access - 字段和控件名称中的空格引起的问题

com - ADODB.Connection 与 "Class does not support Automation"的 Exe 崩溃

vb6 - 如何从函数返回值

vb.net - VB6 程序看不到 VB.Net COM DLL 的属性

c# - VB6 中的复合字符串格式化(即要格式化的字符串中的 : using {0}, {1} 和 {2})

c++ - CDaoDatabase断言错误

C# 数据库合并/复制

regex - 否定正则表达式中的特定组

sql - 来自多个表的关联 SQL 连接查询

sql - 如何在ms access中使用distinct