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
Solved

Access Runtime 3265 - Item not found in this collection

Posted on 2009-04-01
6
1,024 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
  • 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

828 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