Solved

Access Runtime 3265 - Item not found in this collection

Posted on 2009-04-01
6
1,025 Views
Last Modified: 2013-11-27
I have this code in a database that works just fine.  I moved it into a new database I'm working on and it throws this error.

The only difference I can see is in the references with Microsoft DAO 3.6 Object Library.  The database that works has this checked.  The one that throws the error does not.

I tried to enable this in the new DB and I get the error:
"Name Conflicts with existing module, project, or library.

It's not already selected in the preferences window.  How do I track this down?


Public Function getRows(tbl As String)
Dim qdf As DAO.QueryDef
Dim db As Database
Set db = CurrentDb()
Set qdf = db.QueryDefs(tbl)                          >>>>>>>>  Error's Here
r = qdf.OpenRecordset.RecordCount
'MsgBox r
Set rs = Nothing
Set db = Nothing
getRows = r
End Function

Open in new window

0
Comment
Question by:keschuster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:fabriciofonseca
ID: 24041234
Try to change

Dim qdf As DAO.QueryDef
Dim db As Database

by


Dim qdf
Dim db


Regards
0
 
LVL 28

Accepted Solution

by:
TextReport earned 500 total points
ID: 24041394
I suspect the value you are passing as your parameter to the getRows function, tbl, is not a valid QueryDef name in your current database.
Cheers, Andrew
0
 

Author Comment

by:keschuster
ID: 24041606
fabriciofonseca - no go - same error

TextReport - tbl is the name of an actual table.  I copied and pasted the name.
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 28

Expert Comment

by:TextReport
ID: 24041627
Then it needs to be in quotes

Set qdf = db.QueryDefs("tbl")

or you need to run it as

?getRows("tbl")

Cheers, Andrew
0
 

Author Closing Comment

by:keschuster
ID: 31565408
I was passing a TABLE name instead of a query...  DOH
0
 
LVL 28

Expert Comment

by:TextReport
ID: 24041832
"I was passing a TABLE name instead of a query... DOH"
The code below will do the same job but will work for a TableName, QueryName or valid SELECT Statement.
Cheers, Andrew
Public Function getRows(tbl As String)
Dim db As DAO.Database
Dim rst as DAO.Recordset
    Set db = CurrentDb()
    Set rst = db.OpenRecordset("SELECT COUNT(*) AS Qty FROM (" & tbl & ")")
    r = rst!Qty
    Set rs = Nothing
    Set db = Nothing
    getRows = r
End Function

Open in new window

0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question