Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Doesn't Recognize Find First

Status
Not open for further replies.

Garridon

Programmer
Mar 2, 2000
718
US
I used this code on a combo box in an Access 2000 database (using 2002):

Private Sub cboSelectAction_AfterUpdate()

Dim rst As Recordset
Set rst = Me.RecordsetClone

rst.FindFirst "lngTaskID=" & cboSelectAction
If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark
End If
rst.Close
Set rst = Nothing


End Sub

It works fine. But when I tried the code in another database (also a 2000 database but using 2002), it tells me it doesn't recognize FindFirst. Is there an option or something turned off?
Linda Adams
Visit my web site for writing and Microsoft Word tips: Official web site for actor David Hedison:
 
This problem may be because Access 2002 uses ADO instead of DAO. The ADO recordset does not support the FindFirst method. It does support a similar method called plain old "Find". Try replacing your code with the following:
[tt]
Private Sub cboSelectAction_AfterUpdate()

Dim rst As Recordset
Set rst = Me.Recordset.Clone

rst.MoveFirst
rst.Find "lngTaskID=" & cboSelectAction
If Not rst.EOF Then

Me.Bookmark = rst.Bookmark
End If
rst.Close
Set rst = Nothing


End Sub
[/tt]
You may also be able to tell because the intellisense (that little droplist that appears after you type the period after rst) will list a different interface for the recordset object.
 
It did find everything, only now I get an error 7951--"You entered an expression that has an invalid refernece to the RecordSetClone property on this line of code:

Set rst = Me.RecordsetClone

Linda Adams
Visit my web site for writing and Microsoft Word tips: Official web site for actor David Hedison:
 
At first I thought that you had unintentionally left out a period in the statement:
[tt]
Set rst = Me.RecordsetClone
[/tt]
If you are using ADO, the Clone method is named plain old "Clone". Maybe that statement should be written:
[tt]
Set rst = Me.Recordset.Clone
[/tt]
or
[tt]
Set rst = Me.Clone
[/tt]
I'm kinda at a loss because I don't know what sort of object "Me" is.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top