CDec in Access SQL is not behaving the same as when used from Access VBA -


according msdn syntax convert number decimal in vba is

cdec(expression) 

i use conversion function in access sql well. eg clng, cint etc...

however when use cdec sometime error

compile error:wrong number of arguments or invalid property assignment 

consider:

in immediate window

? cdec(round(0.00023,4)) 0.0002   ? cdec(round(0.12345678+0.00000001,6)) 0.123457   ? cdec(round(0.12345679,6)) 0.123457   ? cdec(round(0.12345679,6),10) gives above error  (ie expected no parameter allowed) 

in sql query column

cdec(round(0.12345678,6)) gives above error.  cdec(round(0.12345678,6),2) works , give answer 0.     parameter do!?  cdec(round(0.12345678,6),2,1) gives above error. 

i guess when function called access sql using different code 1 used vba. however, i'm stuck , don't understand.

help!

i'm using ms access 2013: build: 15.0.4727.1003 32bit

harvey

dennis wilmar of ms tells, confirmed bug access 2003 - not removed:

error message when use cdec() function in access query

the suggested work-around wrap cdec in custom function:

function newcdec(myval)    newcdec = cdec(myval) end function 

Comments