Type Mismatch in MySQL


I am in the process of migrating from Access to MySQL and the following is a snippet of code that used to work but now doesn't.

Do Until objRec.EOF
  curRCValTotal = curRCValTotal + objRec.Fields("fldRCVal")

I get the following error:

Microsoft VBScript runtime (0x800A000D)
Type mismatch

MySQL doesn't have a currency datatype like Access did so it is set to type 'decimal(10,2)' I have checked the data type of the recordset field ('fldRCVal') and the result is '14' or VB decimal. I have tried converting the datatype to currency like so:

CCur(curRCValTotal) = CCur(curRCValTotal) + CCur(objRec.Fields("fldRCVal"))

but I get the following error:

Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'CCur'

Any suggestions?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:

curRCValTotal = CCur(curRCValTotal) + CCur(objRec.Fields("fldRCVal"))

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Often you will get this error if the fldRCVal field is set to NULL
To overcome, try the following:

curRCValTotal = CCur("0" & Trim(curRCValTotal)) + CCur("0" & Trim(objRec.Fields("fldRCVal")))

That adds a zero to the beginning of the value. So, 1.45 becomes 01.45 and is translated correctly. NULL becomes "0" and translates correctly.
Ryan ChongCommented:
I think Trim(curRCValTotal) may error too if curRCValTotal contains NULL value, so maybe this better...

curRCValTotal = CCur("0" & Trim("" & curRCValTotal)) + CCur("0" & Trim("" & objRec.Fields("fldRCVal")))

or maybe...

curRCValTotal = 0
if isnumeric(objRec.Fields("fldRCVal")) then
    curRCValTotal = curRCValTotal + objRec.Fields("fldRCVal")
end if

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.