删除多个记录时删除命令有错误。 [英] Delete Command has error when deleting multiple records.

查看:92
本文介绍了删除多个记录时删除命令有错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我在这里工作了多次删除,但出于某种原因我偶尔会遇到这个错误。删除的工作方式是有一个文本框,用户输入要删除的数量。如果它是空白,它将删除1项。当我只删除1个项目时,它永远不会失败,但如果我删除了多个项目,它会失败但只有一些时间。这是错误:


运行时错误''2046'':


命令或操作''DeleteRecord''现在不可用。


这是我的代码:


Private Sub cmdMultiDeleteRecord_Click()

Dim DeletedQty作为整数


如果Me.Dirty然后Me.Dirty = False


DoCmd.SetWarnings(WarningsOff)


如果不是IsNull(Me.NumberDeleted)那么

DeletedQty = Me.NumberDeleted

否则

DeletedQty = 1

结束如果


如果MsgBox(您确定要删除& DeletedQty&记录吗?), vbQuestion + vbYesNo,确认删除?)= vbYes然后


For I = 1 To DeletedQty

DoCmd.RunCommand acCmdDeleteRecord ***错误发生这里****

RunCommand acCmdSelectRecord


接下来我


MsgBox DeletedQty& "记录被删除!,vbOKOnly,记录已删除


结束如果


Exit_cmdMultiDeleteRecord_Click:


DoCmd.DoMenuItem acFormBar,acRecordsMenu,5,acMenuVer70

DoCmd.SetWarnings(WarningsOn)


NumberDeleted.Value = Null


结束子


有人可以帮助我,找出它为什么不起作用吗?


谢谢,


凯文

Hi All,

I got a multiple delete working here but for some reason I occassionally get this error. The way the delete works is there is a text box where the user enters the quantity to delete. If it is blank it will delete 1 item. It never fails when I delete just 1 item but if I delete more than one item it fails but only some times. Here is the error:

"Run-time error ''2046'':

The command or action ''DeleteRecord'' isn''t available now."

Here is my code:

Private Sub cmdMultiDeleteRecord_Click()
Dim DeletedQty As Integer

If Me.Dirty Then Me.Dirty = False

DoCmd.SetWarnings (WarningsOff)

If Not IsNull(Me.NumberDeleted) Then
DeletedQty = Me.NumberDeleted
Else
DeletedQty = 1
End If

If MsgBox("Are you sure you want to delete " & DeletedQty & " record(s)?", vbQuestion + vbYesNo, "Confirm Delete?") = vbYes Then

For I = 1 To DeletedQty
DoCmd.RunCommand acCmdDeleteRecord *** Error Occurs Here ****
RunCommand acCmdSelectRecord

Next I

MsgBox DeletedQty & " record(s) deleted!", vbOKOnly, "Record Deleted"

End If

Exit_cmdMultiDeleteRecord_Click:

DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
DoCmd.SetWarnings (WarningsOn)

NumberDeleted.Value = Null

End Sub


Can somebody help me out and find out why it''s not working?

Thanks,

Kevin

推荐答案

凯文,

你有删除并选择错误的顺序....选择在删除之前。
Kevin,
You have the delete and select in the wrong order....select comes before delete.
展开 | 选择 | Wrap | 行号


非常感谢!这解决了我的问题。我喜欢这个论坛。
Thanks a lot! That fixed my problem. I love this forum.


这个问题仍然存在,但只有当我删除大量的200个时。任何100以下的东西似乎都能正常工作。


还有其他想法吗?


Kevin
The problem still exists but only when I''m deleting a large quantity like 200. Anything under 100 seems to work fine.

Any other ideas?

Kevin


这篇关于删除多个记录时删除命令有错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆