Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access Runtime 3265 - Item not found in this collection

Posted on 2009-04-01
6
Medium Priority
?
1,040 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 2000 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

618 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