[Last Call] Learn how to a build a cloud-first strategyRegister Now


Type Mismatch in MySQL

Posted on 2006-04-04
Medium Priority
Last Modified: 2008-02-01

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?

Question by:leefirth
  • 2
LVL 54

Accepted Solution

Ryan Chong earned 500 total points
ID: 16377839

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

Expert Comment

ID: 16382041
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.
LVL 54

Expert Comment

by:Ryan Chong
ID: 16382096
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


Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question