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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time error '13' 1

Status
Not open for further replies.

Natha2

Programmer
Dec 23, 2004
17
0
0
BE
Hi,

My form contains an unbound textbox named "txtFind".
User is supposed to enter a customer id number and type 'enter'.
Event behind "txtFind" is:

Private Sub txtFind_AfterUpdate()
Dim rs As ADODB.Recordset
Dim x

x = DLookup("Customer_nr", "CUSTOMERS", "Customer_nr = " & txtFind)

If IsNull(x) Then
MsgBox "Customer not in database.", vbExclamation, "Prepaid Search Engine"
Else
Set rs = Me.RecordsetClone
rs.Find "Customer_nr = " & txtFind
Do
Err.Clear
Me.Bookmark = rs.Bookmark
If Err = 0 Then Exit Do
DoEvents
Loop
End If
End Sub

When testing it, I get following error:

"Run-time error '13'
Type Mismatch"

The code gets stuck on line: "Set rs = Me.RecordsetClone"
It seems that he does not recognize rs as recordset datatype, because rs=Nothing.

Anyone has a clue?

Thanx,
Natha
 
Unless you're working with an ADP, or have explicitly set your form recordset to an ADO recordset, it is DAO.

Try:

[tt]Dim rs As DAO.Recordset[/tt]

and ensure you have a reference to Microsoft DAO <version> Object Library (in VBE - Tools | References). You'll need to replace the .Find method with the .FindFirst method too.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top