Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 1999-07-16
5
Medium Priority
?
292 Views
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?
0
Comment
Question by:lbowers
[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
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:CraigLazar
ID: 1506724
Hi
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.

:0)

Craig
0
 
LVL 18

Expert Comment

by:mdougan
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:

....
Data1.Refresh
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") & ""

0
 

Author Comment

by:lbowers
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?

Thanks.
0
 

Author Comment

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

Weird eh?
0
 
LVL 18

Accepted Solution

by:
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*'"

Data1.Refresh

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Suggested Courses

661 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