Runtime Error 3001

M

Morten Snedker

When trying to perform a Recordset.Find I get a runtime error 3001.

I'm using the following code:

rsFind.Open "Select IDAfdeling, cvrnr, afdeling, adresse1 From
tblCVRAfdeling", con, adOpenDynamic, adLockReadOnly

rs.MoveFirst
Do Until rs.EOF
rsFind.MoveFirst
rsFind.Find "Afdeling='" & rs!Afdeling & "' AND cvrnr='" &
rs!cvrnr & "' AND Adresse1='" & rs!adresse & "'"

A debug shows:
Afdeling='Teknisk Forvaltning' AND cvrnr='58271713' AND
Adresse1='Hold-an Vej 7'

Sending the enitre statement to Query Analyzer turns out ok.

If I use rsFind.Find on each of the three criterias alone the Find
method works.

I've been googling a bit, but can't seem to find my solution.

Thanks in advance.


/Snedker
 
M

Michel Walsh

Hi,


ADO recordset method FIND does not accept compound criteria (with AND or
OR). Do the search INSIDE the string opening the recordset, that is faster
than using Find, anyhow:

rsFind.Open "Select IDAfdeling, cvrnr, afdeling, adresse1 From
tblCVRAfdeling WHERE Afdeling='" & rs!Afdeling & "' AND cvrnr='" &
rs!cvrnr & "' AND Adresse1='" & rs!adresse & "'",
con, adOpenDynamic, adLockReadOnly




Hoping it may help,
Vanderghast, Access MVP
 
M

Morten Snedker

On Mon, 30 Aug 2004 06:31:09 -0400, "Michel Walsh"

Found it out beforehand. Though, it's kinda annoying since I have to
do a loop opening and closing the recordset several thousand times,
instead of just opening the recordset and do the searches. But maybe
it makes no difference when it comes to performance.

But thanks for your reply! :)

Regards /Snedker
 
B

Brendan Reynolds

You could use the Filter method, which I believe does accept multiple
criteria. I'm not sure whether it will prove faster, but it may be worth
looking into.

--
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