FindFist not working

M

Max

Access 2007 SP1.
PBT is a table and [ID] is a Number (Double)
Error 3251, Operation is not supported for this type of object. Debug opens
on last line of code highlighted:
Dim rstPBT As Recordset
Set rstPBT = CurrentDb().OpenRecordset("PBT")
rstPBT.FindFirst "[ID] = " & Form![ID]

What is my problem on that last line?? or is it in the Set statement??
Thanks in advance.
 
B

Beetle

rstPBT.FindFirst "[ID] = " & Forms!NameOfTheForm![ID]

OR, if this code is behind the form in question;

rstPBT.FindFirst "[ID] = " & Me![ID]
 
M

Max

Sean,

Tried your suggestion and still get the same error. Could there be a
problem with the Set command? Does it need an additional parameter after the
table name?

Thanks again.



Beetle said:
rstPBT.FindFirst "[ID] = " & Forms!NameOfTheForm![ID]

OR, if this code is behind the form in question;

rstPBT.FindFirst "[ID] = " & Me![ID]

--
_________

Sean Bailey


Max said:
Access 2007 SP1.
PBT is a table and [ID] is a Number (Double)
Error 3251, Operation is not supported for this type of object. Debug opens
on last line of code highlighted:
Dim rstPBT As Recordset
Set rstPBT = CurrentDb().OpenRecordset("PBT")
rstPBT.FindFirst "[ID] = " & Form![ID]

What is my problem on that last line?? or is it in the Set statement??
Thanks in advance.
 
M

ManuPR

Hi Max,

The problem is that the FindFirst method only works for Dynaset or Snapshot
recordset types.
Try the following:

Set rstPBT = CurrentDb().OpenRecordset("PBT", dbOpenDynaset)

If you specifically wanted to open the recordset as a table you can try the
"Seek" method.
 
M

Max

Thanks! That worked.


ManuPR said:
Hi Max,

The problem is that the FindFirst method only works for Dynaset or Snapshot
recordset types.
Try the following:

Set rstPBT = CurrentDb().OpenRecordset("PBT", dbOpenDynaset)

If you specifically wanted to open the recordset as a table you can try the
"Seek" method.

Max said:
Access 2007 SP1.
PBT is a table and [ID] is a Number (Double)
Error 3251, Operation is not supported for this type of object. Debug opens
on last line of code highlighted:
Dim rstPBT As Recordset
Set rstPBT = CurrentDb().OpenRecordset("PBT")
rstPBT.FindFirst "[ID] = " & Form![ID]

What is my problem on that last line?? or is it in the Set statement??
Thanks in advance.
 
J

John W. Vinson

Dim rstPBT As Recordset
Set rstPBT = CurrentDb().OpenRecordset("PBT")
rstPBT.FindFirst "[ID] = " & Form![ID]

What is my problem on that last line?? or is it in the Set statement??
Thanks in advance.

It's probably your References. There are two different kinds of Recordset
objects, ADO and DAO; depending on your version of Access, it may be that ADO
is the default. A CurrentDb.OpenRecordset action creates a DAO recordset, and
FindFirst expects one.

Try Dim rstPBT AS DAO.Recordset, and/or use Tools... References to enable DAO
3.x and disable Access Data Objects...
 

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