DAO to ADO and Finding records

J

johnb

I have the following code that works fine in DAO but when change to ADO it
fails and I've run out of ideas to try. And pointers please.

Private Sub FindCourse(varCourse As Variant)
Dim LV As Variant

Dim rec As DAO.Recordset ' I change this to ADODB.recordset

Dim strBookmark As String
LV = Trim(varCourse)
If IsNull(varCourse) Then
MsgBox "No Record Found", vbInformation, "Error!"
Exit Sub
End If
'If Me.Dirty Then
'Me.Dirty = False
'End If

Forms!CourseDetails.SetFocus
DoCmd.GoToControl Forms!CourseDetails!Field94.Name

Set rec = Forms!CourseDetails.RecordsetClone

rec.FindFirst "[CourseCounter] = " & CLng(LV) ' & """" 'CStr()

If Not rec.NoMatch Then ' Change to If rec.EOF Then

strBookmark = rec.Bookmark
Forms!CourseDetails.Bookmark = strBookmark
End If

DoCmd.GoToControl Forms!CourseDetails!Field94.Name
DoCmd.Close A_FORM, "fdlgFind"
rec.Close

End Sub
 
Top