Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-Time error '3265' Item not found in this collection

Status
Not open for further replies.

daveinchicago

IS-IT--Management
Feb 13, 2012
19
US
If Not (Me.sfCategory.Form.Recordset.EOF And Me.sfCategory.Form.Recordset.BOF) Then
If MsgBox("Are you sure you want to Delete?", vbYesNo) = vbYes Then
CurrentDb.Execute "Delete from dbo_COMPLIANCE_CATEG " & _
"where ID=" & Me.sfCategory.Form.Recordset.Fields("ID")
Me.sfCategory.Form.Requery
End If
End If


I've got the above code tied to a button in Access 2010. The subform is a SQL Table. When I highlight a row in the subform (SQL Table) and hit the 'delete' button, the row should delete. However, I am getting a
Run-Time error '3265' Item not found in this collection.

When I coded this using local tables it worked perfectly. not sure what I'm doing wrong.

Thanks.
 
Check out faq705-7148. Always Dim strSQL so you can find your issues. Also, learn how to use TGML since you seem to be posting a few questions here.

Tell us which line of code is causing the error. You may need something regarding dbSeeChanges.

Code:
Dim strSQL As String
If Not (Me.sfCategory.Form.Recordset.EOF And _
       Me.sfCategory.Form.Recordset.BOF) Then
    If MsgBox("Are you sure you want to Delete?", vbYesNo) = vbYes Then
        strSQL = "Delete from dbo_COMPLIANCE_CATEG " & _
          "where ID=" & Me.sfCategory.Form.Recordset.Fields("ID")
        debug.print strSQL
        CurrentDb.Execute strSQL, dbFailOnError
        Me.sfCategory.Form.Requery
    End If
End If

Duane
Hook'D on Access
MS Access MVP
 
my guess is that the ID field is no longer simply ID. Find out the real name

dim fld as dao.field
for each fld in Me.sfCategory.Form.Recordset.Fields
debug.print fld.name
if fld.name = "ID" then
msgbox "ID found
end if
next fld
 
adding dbseechanges corrected the problem

thanks.

What is TGML?
 
TGML is the markup that allows you to post formatted content in this site such as my reply with the Code section. This makes postings much easier to read. You can format colors, fonts, backgrounds, and more.

Always use the [Preview Post] button. There is additional help information available in the preview.

Duane
Hook'D on Access
MS Access MVP
 
How are ya daveinchicago . . .

Also:
Code:
[blue]   Me.sfCategory.Form.Recordset.Fields("ID")
[green]'is the same as:[/green]
   Me.sfCategory.Form.Recordset.ID
[green]'as well as:[/green]
   Me.sfCategory.Form.Recordset!ID[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
ok, now I have a similar problem with the code below.

If Not (Me.sfRULENOTE.Form.Recordset.EOF And Me.sfRULENOTE.Form.Recordset.BOF) Then
If MsgBox("Are you sure you want to Delete?", vbYesNo) = vbYes Then
CurrentDb.Execute "Delete from dbo_COMPLIANCE_ACCT_NOTE where ID=" & Me.sfRULENOTE.Form.Recordset.ID, dbSeeChanges
Me.sfRULENOTE.Form.Requery
End If
End If

I'm getting an error saying that I need to use dbSeeChanges. But I am.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top