Findfirst in Access 2003

B

beacon

After opening a recordset e.g. Set rs = db.Openrecordset("tblone") and then
run the program with rs.Findfirst strwhere it get the message "Operation not
supported on this type of object".
The table tblone is in the database so what do I need to do?
 
D

Douglas J. Steele

Recordset is an object in both the ADO and DAO models. While Access 2003 has
references set for both models (unlike Access 2000 or 2002, which only had a
reference to ADO by default, or Access 97 or earlier, which only had a
reference to DAO), ADO is higher in the list of references, meaning that it
gets precedence.

That means that if you declared your object as

Dim rs As Recordset

by default it's been declared as an ADO recordset, which does not support
the FindFirst method.

Use

Dim rs As DAO.Recordset

instead (to guarantee an ADO recordset, use Dim rs As ADODB.Recordset)

If you don't intend to use ADO in your application, you could go into the
references (Tools | References when you're in the VB Editor) and remove the
reference to Microsoft ActiveX Data Objects 2.x Library (but even if you do
this, I'd still recommend using the disambiguation above for clarity sake)
 
A

Andi Mayer

After opening a recordset e.g. Set rs = db.Openrecordset("tblone") and then
run the program with rs.Findfirst strwhere it get the message "Operation not
supported on this type of object".
The table tblone is in the database so what do I need to do?

is rs a DAO.recordset???

Set rs = db.Openrecordset("tblone",dbopendynaset)
 
B

Brendan Reynolds

When you don't specify the second, optional, 'Type' argument of the
OpenRecordset method, it defaults to dbOpenTable if the table is local (it
defaults to dbOpenDynaset if the table is linked). You can't use the
FindFirst (or FindNext, etc) methods with dbOpenTable. Specify dbOpenDynaset
(as Andi Mayer suggests elsewhere in this thread) and that should sort it.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top