Run time error 13 - recordset find

  • Thread starter Thread starter Julia Boswell
  • Start date Start date
J

Julia Boswell

Folks,

I'm getting a runtime error 13 "datatype mismatch" when running a bit of
code. I'm looping through a recordset (ADODB), and comparing it with another
recordset to find a record. The line where I'm getting the problem is:

rsTest.Find ("[TestNo] = '" + rsTemp!TestNo + "'")

Both recordsets have been opened, I've ensured that I'm at the beginning of
rsTest before this, and both fields TestNo are of type Autonumber, so I
can't work out what the problem is.

I can't see how it can be syntax, as I have an identical line of code in
another form in the same db looking at 2 different fields and this works
fine.

Any ideas?

Much appreciated.

Julia
 
The single quotes should not be used when testing against
numbers. Try
rsTest.Find ("[TestNo] = " & rsTemp!TestNo)

Hope This Helps
Gerald Stanley MCSD
 
Fantastic, that worked fine! How strange though that my syntax worked fine
in another form searching 2 number fields......

Thanks!

Julia
Gerald Stanley said:
The single quotes should not be used when testing against
numbers. Try
rsTest.Find ("[TestNo] = " & rsTemp!TestNo)

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
Folks,

I'm getting a runtime error 13 "datatype mismatch" when running a bit of
code. I'm looping through a recordset (ADODB), and comparing it with another
recordset to find a record. The line where I'm getting the problem is:

rsTest.Find ("[TestNo] = '" + rsTemp!TestNo + "'")

Both recordsets have been opened, I've ensured that I'm at the beginning of
rsTest before this, and both fields TestNo are of type Autonumber, so I
can't work out what the problem is.

I can't see how it can be syntax, as I have an identical line of code in
another form in the same db looking at 2 different fields and this works
fine.

Any ideas?

Much appreciated.

Julia


.
 
Julia,

Is the field TestNo in both recordsets text or numeric? If the text is
numeric, you need to remove the '. e.g.

rsTest.Find ("[TestNo] = " & rsTemp!TestNo)

The datatype mismatch error means it is searching for a perticular type
(number, text, date etc), but the wrong type has been passed in (' is for
text and # is for date). I have used the & in the above example instead of +
as I find it easier to read. When I use the + I automatically assume that I
am adding something. Although both work i just get confused when using +
:-).

Hope this helps,

Neil.
 
Back
Top