Type mismatch error - help please

Z

zenfor

Hi, appreciate any help with this, I can't seem to get past this error.
The Price field is a Number Data Type.

This is part of some code that is adding records to a database. The 3
lines of x_author (text data type) works fine. The error is coming at
the "rs("price") = tmpFld" line. I assume I don't have it defined
correctly but not quite sure how to fix it. Thanks!
===========================


tmpFld = Trim(x_author)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("author") = tmpFld

------->ERROR HERE!!
tmpFld = Trim(x_price)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("price") = tmpFld
 
F

Firas S Assaad

Hi,

Propably the problem is that the tmpFld variable is set to Null
i dont think a number type fiedl in the database can accept null value.

Try this, just to make sure:
replace the Null with a 0 and see if still gets out the same error. If
it does then replace this line:
rs("price") = tmpFld
with:
rs("price") = int(tmpFld)

Tell me what goes on with u.

Best Regards
Firas S Assaad
 
M

Mike Brind

zenfor said:
Hi, appreciate any help with this, I can't seem to get past this error.
The Price field is a Number Data Type.

This is part of some code that is adding records to a database. The 3
lines of x_author (text data type) works fine. The error is coming at
the "rs("price") = tmpFld" line. I assume I don't have it defined
correctly but not quite sure how to fix it. Thanks!
===========================


tmpFld = Trim(x_author)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("author") = tmpFld

------->ERROR HERE!!
tmpFld = Trim(x_price)
If trim(tmpFld) & "x" = "x" Then tmpFld = Null
rs("price") = tmpFld

Could you be a bit more explicit about which liine throws an error, and what
the error is? You say that the line rs("price") = tmpFld causes the error
in your preamble, but the code suggests the error is being thrown at tmpFld
= Trim(x_price).

Where does x_price get its value from? Also, why are you creating a
recordset to perform an Insert? And what type and version of database are
you using?
 

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


Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top