访问删除命令问题 [英] Access Delete Command Issue

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

问题描述

我仍然工作走这种形式,现在我ecountering与删除code部分的错误。我相信这是有一个问题,认识我选择什么,但我可能是错的。该错误信息读取运行时错误3265没有找到在此集合

整个code读取:

 私人小组cmdDelete_Click()
删除记录
检查现有的选择的记录
如果不是(Me.TableSub.Form.Recordset.EOF而Me.TableSub.Form.Recordset.BOF)然后
    确认删除
    如果MSGBOX(你确定要删除这个记录吗?,vbYesNo)= vbYes然后
    立即删除
    CurrentDb.ExecuteDELETE FROM KWTable WHERE text_key ='&放大器; Me.TableSub.Form.Recordset.Fields(text_key)及'
        列表中的刷新数据
        Me.TableSub.Form.Requery
    结束如果
结束如果
结束小组
 

这是突出的部分是:

  CurrentDb.ExecuteDELETE FROM KWTable WHERE text_key ='&放大器; Me.TableSub.Form.Recordset.Fields(text_key)及'
 

解决方案

在错误指示子窗体的记录不包括一个名为领域的 text_key 的。

在细节,你得到错误#3265,项目不在此集合找到。的在code中的唯一的地方可能引发的误差 Me.TableSub.Form.Recordset.Fields(text_key)。你知道 Me.TableSub.Form.Recordset 是有效的,因为如果不是,那么你会得到一个错误较早(在如果不( Me.TableSub.Form.Recordset ... ),这意味着该记录的字段集合不包括项目命名的text_key的。

如果您修改code为@JohnnyBones建议,您将继续得到同样的错误,但错误然后在MySQLString = ...行,而不是 CurrentDb.Execute 行。

当你得到该错误信息,单击调试按钮,并使用这个在立即窗口中列出该记录

字段的名字

在Me.TableSub.Form.Recordset.Fields每个F:_ ? f.Name:_ 下一个

注意 _ 续行字符。您必须使用前至少1空间和之后的每个 0的空间_

I am still working away on this form and now I am ecountering an error with the delete code portion. I believe it is having a problem recognizing what I am selecting but I could be wrong. The error message reads RUN TIME ERROR 3265 ITEM NOT FOUND IN THIS COLLECTION

The whole code reads:

Private Sub cmdDelete_Click()
'delete record
'check existing selected record
If Not (Me.TableSub.Form.Recordset.EOF And Me.TableSub.Form.Recordset.BOF) Then
    'confirm delete
    If MsgBox("Are you sure you want to delete this record?", vbYesNo) = vbYes Then
    'delete now
    CurrentDb.Execute "DELETE FROM KWTable WHERE text_key='" &     Me.TableSub.Form.Recordset.Fields    ("text_key") & "'"
        'refresh data in list
        Me.TableSub.Form.Requery
    End If
End If
End Sub

And the portion that is highlighted is:

CurrentDb.Execute "DELETE FROM KWTable WHERE text_key='" & Me.TableSub.Form.Recordset.Fields    ("text_key") & "'"

解决方案

The error indicates the subform's Recordset does not include a field named text_key.

In detail, you are getting error #3265, "Item not found in this collection." The only place in the code which could trigger that error is Me.TableSub.Form.Recordset.Fields("text_key"). You know Me.TableSub.Form.Recordset is valid, because if it weren't then you would have gotten an error earlier (on If Not (Me.TableSub.Form.Recordset ...). That means the recordset's Fields collection does not include an Item named "text_key".

If you revise the code as @JohnnyBones suggested, you will continue to get the same error, but the error will then be triggered at the "MySQLString = ..." line instead of the CurrentDb.Execute line.

When you get that error message, click the Debug button, and use this in the Immediate window to list the names of the fields in that Recordset.

for each f in Me.TableSub.Form.Recordset.Fields: _
? f.Name : _
next

Note the _ line continuation characters. You must use at least 1 space before and 0 spaces after each _

这篇关于访问删除命令问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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