我仍在处理此表单,现在我遇到了删除代码部分的错误。我相信在识别我选择的内容时遇到问题,但我可能是错的。错误消息显示为 RUN TIME ERROR 3265 ITEM NOT FOUND IN THE COLLECTION
整个代码如下:
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
突出显示的部分是:
CurrentDb.Execute "DELETE FROM KWTable WHERE text_key='" & Me.TableSub.Form.Recordset.Fields ("text_key") & "'"