DAO 3.6 & "Item not found in this collecion"...

Posted on 1999-07-16
Medium Priority
Last Modified: 2013-12-25
I'm updating my applications to use Access 2000 databases using VB6 SP3's DAO 3.6.
Whenever I do a <data control>.Refresh and the data control's recordset is empty, I'm getting an "Item not found in collection" error. The very same piece of code used to work with DAO 3.51! Anyone know what's wrong and how to solve it?
Question by:lbowers
  • 2
  • 2

Expert Comment

ID: 1506724
Someone posted the exact problem i think yestersday.
I think it is a problem with the Data control and the new version of dao that is causiong the error. Unless Microsoft has brought out a pathc or an updated control you might have to go with out the data control and create recordset using sql and populate your fields or db grids.

Sorry this is not very helpfull but like i said earlier this seems to be quite a problem now with Access 2000,
Maybe post the question in the Access topic area , someone might be able to help u there.


LVL 18

Expert Comment

ID: 1506725
Does the error happen on the Refresh line, or on a subsequent line where you try to access one of the columns of the recordset? If so, then try something like:

If Data1.Recordset.Bof or Data1.Recordset.EOF then Exit sub
' or try
' if Data1.Recordset.Recordcount < 1 then Exit Sub

txtName.text = Data1.Recordset("EmpName") & ""


Author Comment

ID: 1506726
Yes - It does happen on the refresh line.

Too much of the code hangs of the Dat Control, so removing that isn't an option sadly...

Is there any other solution?


Author Comment

ID: 1506727
I've also tried using the .RecordCount < 1 method and it only works *sometimes*!

Weird eh?
LVL 18

Accepted Solution

mdougan earned 300 total points
ID: 1506728
Well, this will work, but it is a total kludge.  Let's say that your RecordSource for the data control has a sql statement that is something like:

Select * from Employees where LastName Like "B*"

To keep from getting the empty recordset that is killing you on the Refresh, do this before.  Change the SQL to:

Select Count(*) as RecCount from Employees where LastName Like "B*"

Then, in your code say:

if Data1.Recordset("RecCount") = 0 then Exit Sub

Data1.RecordSource = "Select * from Employees where LastName Like 'B*'"



Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

627 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