Recordset clone fails

B

Bakema

I am trying to use a combobox and recordset clone property to search for
records in a form. The record selected in the combobox should be compared
with the record set and then the form record should be moved to the selected
record as follows:

Private Sub Combotest_AfterUpdate()

Dim rstCriteria As String
Dim rstClone As ADODB.Recordset

Set rstClone = Me.RecordsetClone

strCriteria = "Test2 = " & Me!Combotest
rstClone.Find strCriteria
Me.Bookmark = rstClone.Bookmark

End Sub

The above procedure comes from a book, but fails to work on the line: Set
rstClone = Me.RecordsetClone with the message 13 type mismatch.

Any ideas why this does not work?

bakema
 
K

Ken Snell [MVP]

A form's recordsetclone will be in DAO recordset format, not ADO. But you
don't need to use a separate recordset object anyway:

Private Sub Combotest_AfterUpdate()

Dim rstCriteria As String
strCriteria = "Test2 = " & Me!Combotest
With Me.RecordsetClone
.Find strCriteria
If .NoMatch = False Then
Me.Bookmark = .Bookmark
Else
Msgbox "There is no such record!"
End If
End With

--

Ken Snell
<MS ACCESS MVP>


End Sub
 
K

Ken Snell [MVP]

Sorry-- typos in my just-sent post -- here is corrected version:

Private Sub Combotest_AfterUpdate()
Dim rstCriteria As String
strCriteria = "Test2 = " & Me!Combotest
With Me.RecordsetClone
.FindFirst strCriteria
If .NoMatch = False Then
Me.Bookmark = .Bookmark
Else
Msgbox "There is no such record!"
End If
End With
End Sub
 
W

Wayne Morgan

Try DIMing rstClone as a DAO.Recordset. You'll also need to change
rstClone.Find to rstClone.FindFirst
 

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