(Simple) problem with RecordsetClone.

  • Thread starter Thread starter RHT
  • Start date Start date
R

RHT

Guest
This code is from the MS Access 2000 VBA Help File (Topic 'RecordsetClone' - Example).

Sub SupplierID_AfterUpdate()
Dim rst As Recordset
Dim strSearchName As String

Set rst = Me.RecordsetClone
strSearchName = Str(Me!SupplierID)
rst.Find "SupplierID = " & strSearchName
If rst.NoMatch Then
MsgBox "Record not found"
Else
Me.Bookmark = rst.Bookmark
End If
rst.Close
End Sub

It runs fine in Access '97 - and possibly Access 2.0 - but doesn't compile when I try it in Access 2000. When the 'compile' hits 'If rst.NoMatch' it returns an error message. (I'm using almost exactly this code attached to a Combo-box to move to the specified record on a form - except my strSearchName is already a string so doesn't need the Str() function.)

Anyone know why it won't work?
 
I think you are missing a library in your references. Maybe an ADO library. To check, hold the alt button and hit the F11 key. Go to Tools and select references. See if any are missing. You will get this error, even if the code is the same between the 3 versions of Access.
 
The RecordsetClone is a DAO recordset so I think you need to define rst as DAO.Recordset.
 

Users who are viewing this thread

Back
Top Bottom