FindFirst 3251

M

meyerryang

I can't figure out why I keep getting a 3251 error. I am looking for a
specific record where I would like to change the note, but it won't let me go
to the record in "My Controls" table where the [Task] field is equal to 2.
It is numerical and all other references on other forms work just fine
(Dlookups, etc). Please help.

Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("My Controls")
rs.FindFirst "[Task] = 2"

rs.Edit
rs!Note = NewQuery

rs.Update
rs.Close: Set rs = Nothing
 
M

meyerryang

Ok, I figured it out. I have to open a dynaset query to use the findfirst
function.

Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("My Controls", dbOpenDynaset)
rs.FindFirst "[Task] = 2"

rs.Edit
rs!Note = NewQuery

rs.Update
rs.Close: Set rs = Nothing
 
S

Stuart McCall

meyerryang said:
Ok, I figured it out. I have to open a dynaset query to use the findfirst
function.
<snip>

Almost right. You actually need a dynaset because you're updating it.
 
D

Dirk Goldgar

Stuart McCall said:
<snip>

Almost right. You actually need a dynaset because you're updating it.


No, actually meyerryang is right. The .FindFirst method doesn't work on a
table-type recordset; only on a dynaset or snapshot-type recordset. In
contrast, the .Seek method only works on a table-type recordset. And if [My
Controls] is the name of a local table, then

Set rs = CurrentDb.OpenRecordset("My Controls")

.... would be opening a table-type recordset.

Note that a table-type recordset is generally updatable, so a dynaset is not
necessary for the recordset to be updatable. A snapshot-type recordset
would not be updatable.
 
S

Stuart McCall

Dirk Goldgar said:
Stuart McCall said:
<snip>

Almost right. You actually need a dynaset because you're updating it.


No, actually meyerryang is right. The .FindFirst method doesn't work on a
table-type recordset; only on a dynaset or snapshot-type recordset. In
contrast, the .Seek method only works on a table-type recordset. And if
[My Controls] is the name of a local table, then

Set rs = CurrentDb.OpenRecordset("My Controls")

... would be opening a table-type recordset.

Note that a table-type recordset is generally updatable, so a dynaset is
not necessary for the recordset to be updatable. A snapshot-type
recordset would not be updatable.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

I actually knew all of that. So why did I post what I did? <shrug> - must be
getting rusty - I've been retired for just over 2 years.

Thanks Dirk.
 

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