Findfirst NOT working with DAO.Recordset

  • Thread starter Alexcamp via AccessMonster.com
  • Start date
A

Alexcamp via AccessMonster.com

Can anyone tell what is wrong with the following code? I am getting an error
3251 "operation is not supported for this type of object"

I've searched the forums but everywhere it is said to use DAO recordset but
that's what i am using !!

Any help will be appreciated. Here's the code:

Dim dbProjet As DAO.Database
Dim tdfProjet As DAO.TableDef
Dim rstProjet As DAO.Recordset

Dim ProjectNumber As Long

Set dbProjet = Nothing
Set tdfProjet = Nothing
Set rstProjet = Nothing

Set dbProjet = CurrentDb
Set tdfProjet = dbProjet.TableDefs("tblProjets") ' Opens the Table
Set rstProjet = tdfProjet.OpenRecordset

ProjectNumber = Me.txtNumero.Value

rstProjet.FindFirst ("[NumeroReel_projet] = " & ProjectNumber)
 
A

Alexcamp via AccessMonster.com

I was wondering, could it be because an opened form is using the table as
source?
 
M

Marshall Barton

Alexcamp said:
Can anyone tell what is wrong with the following code? I am getting an error
3251 "operation is not supported for this type of object"

I've searched the forums but everywhere it is said to use DAO recordset but
that's what i am using !!

Any help will be appreciated. Here's the code:

Dim dbProjet As DAO.Database
Dim tdfProjet As DAO.TableDef
Dim rstProjet As DAO.Recordset

Dim ProjectNumber As Long

Set dbProjet = Nothing
Set tdfProjet = Nothing
Set rstProjet = Nothing

Set dbProjet = CurrentDb
Set tdfProjet = dbProjet.TableDefs("tblProjets") ' Opens the Table
Set rstProjet = tdfProjet.OpenRecordset

ProjectNumber = Me.txtNumero.Value

rstProjet.FindFirst ("[NumeroReel_projet] = " & ProjectNumber)


The problem is that you are opening the wrong type of
recordset. A table type recordset can use Seek, but not
FindFirst.

Dim db As DAO.Database
Dim rs As DAO.Recordset

Dim ProjectNumber As Long

Set db = CurrentDb()
Set rs = db.OpenRecordset("tblProjets",dbOpenDynaset)

ProjectNumber = Me.txtNumero.Value

rs.FindFirst "NumeroReel_projet=" & ProjectNumber
, , ,

rs.Close : Set rs = Nothing
Set db = Nothing
 
A

Alexcamp via AccessMonster.com

Thank you Marshall !!!

That worked right away.
Obviously these recordset things are bit complicated. Any useful
tutorials/informationnal links on the subject you can suggest ?

Thanks again.

Alex
 
M

Marshall Barton

Alexcamp said:
Thank you Marshall !!!

That worked right away.
Obviously these recordset things are bit complicated. Any useful
tutorials/informationnal links on the subject you can suggest ?


I think most good books on Access will discuss the topic,
but I figured out most of it by using VBA Help.
 

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