FindFirst error

G

Guest

I have two tables. I'm trying to see if a record exists in my second table
using the FindFirst method. My first table (rec) is indexed but my second
table (rec1) is not. It could be, if needed.

Both 'MasterRecID' fields below are numbers, not strings.

After the FindFirst code executes, I receive the following error, "3251:
Operation not supported for this type of object"

Thanks for your help.


Dim rec As Recordset
Dim db As Database
Set db = CurrentDb()
Set rec = db.OpenRecordset("qryNADispensings1")

Dim rec1 As Recordset
Dim db1 As Database
Set db1 = CurrentDb()
Set rec1 = db1.OpenRecordset("tblNAReport")

If rec.EOF Then
rec.Close
MsgBox "No data", vbInformation, ""
Exit Sub
Else
rec.MoveFirst
Do
rec1.FindFirst "MasterRecID = " & rec("MasterRecID")

If rec1.NoMatch Then
MsgBox "No match!"
Else
MsgBox "match!"
End If

rec.MoveNext
If rec.EOF Then Exit Do

Loop
End If
 
K

Ken Snell [MVP]

You need to declare the recordsets as DAO recordsets because you're likely
using ACCESS 2000 or 2002 both of which assume that you want to use an ADO
recordset (which does not have a FindFirst method):

Dim rec As DAO.Recordset
Dim rec1 As DAO.Recordset
 
K

Ken Snell [MVP]

When the error occurs, and you check Debug button on message window, which
line of code is highlighted in yellow?
 

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

Similar Threads


Top