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

Jason S

New member
Local time
Today, 08:29
Joined
Jan 2, 2013
Messages
1
I am using an unbound control on a form for a user to enter the criteria to search against. I want the one matching record from a table based on the entered criteria and to populate the remaining controls with additional fields in the record. I haven't reached the point of understanding how to use the additional fields yet because I haven't get my select query to work yet.

I am using the code in thread #221226 to execute a select query using a public module. (Included below)

Code:
Public Sub QDef(strSql As String)

Dim db As DAO.Database
Dim qdfTemp As QueryDef
Dim strSeason As String
Dim strDocName As String
    Set db = CurrentDb
    strDocName = "qryQueries"
    db.QueryDefs.Delete strDocName
    Set qdfTemp = db.CreateQueryDef("qryQueries")
    qdfTemp.SQL = strSql
    DoCmd.OpenQuery strDocName
End Sub

I have verified that the field names in the select statement are an exact match in the table ADInfo. I suspected that the spaces in the field names were the cause of the error however after temporarily removing thiem from the table and the code below I had the same result.

Any insight you can provide is most appreciated. even if this means using a different approach.

Code:
User = [Forms]![Users].[Form]![txtSearchString]
qryUser = "Select [Display Name] From ADInfo WHERE [User Name]='" + User + "';"

EDITED by The_Doc_Man to correct code tags; no other edits made. 4/20/22
 
Last edited by a moderator:
Hi Jason, There is not much to information to go with this..
* Which thread number are you referring to?
* Which line is the error occurring at?
* What is exactly that you are doing here? I mean is the tctSearchString in a SubForm?
Code:
User = [Forms]![Users].[Form]![txtSearchString]
* Concatenation normally involves & not +
 
If you're having problem with Run time 3265 "Item not found in this collection, there is no rime or reason why it appears. Some items in the record are read, some others are not. Like Cname= rstRecords![Customer.Name] gave me the dreadful error 3265 even if the query result showed me the content of that item.
I have found that if you know the structure of the query result, like were Customer.Name resides, let say in the first Field, or index 0, you can use this method:
Cname= rstRecords.Fields(0) it works for me just the same, no, it works ! All other records would be .Field(0....5)
Louis Larocque
 
a..err.. see the Post date first:unsure:
 

Users who are viewing this thread

Back
Top Bottom