Implicit type conversion

R

Ron Hinds

In Access 97, Access would perform implicit conversion of data in a text box
to, e.g., a Currency when used in an expression like so:

If txt_price > txt_sellprice Then

However, in Access 2003 this test doesn't perform as expected unless I
explicitly cast the text box value to Currency, like so:

If CCur(txt_price) > CCur(txt_sellprice) Then

Is there a setting or option somewhere that governs this behavior? Or am I
going to have to go through my entire app looking for expressions like this
and explicity casting them?
 
A

Albert D. Kallal

Ron Hinds said:
In Access 97, Access would perform implicit conversion of data in a text
box to, e.g., a Currency when used in an expression like so:

If txt_price > txt_sellprice Then

However, in Access 2003 this test doesn't perform as expected unless I
explicitly cast the text box value to Currency, like so:

If CCur(txt_price) > CCur(txt_sellprice) Then

Is there a setting or option somewhere that governs this behavior? Or am I
going to have to go through my entire app looking for expressions like
this and explicity casting them?


I not aware that there was a change in this behaviors/regards. However, if
you are using un-bound text boxes, then they tend to take on the type that
they are FIRST set to (they are thus "variant" types).

If both of those text boxes are bound, then I can't possible see the need to
"cast" the data type as your 2nd example shows.

So, no, there is no global setting, but I am not aware that things changed
from 97 to a2003 in this regards at all....

I am guessing, but if those text boxes are un-bound, then you have to setup
a default value for them...perhaps even use code to stuff in a value of zero

me.txt_price = ccur(0)

The text boxes will be of type varient if they are un-bound.
 
R

Ron Hinds

Albert D. Kallal said:
I not aware that there was a change in this behaviors/regards. However, if
you are using un-bound text boxes, then they tend to take on the type that
they are FIRST set to (they are thus "variant" types).

If both of those text boxes are bound, then I can't possible see the need
to "cast" the data type as your 2nd example shows.

So, no, there is no global setting, but I am not aware that things changed
from 97 to a2003 in this regards at all....

I am guessing, but if those text boxes are un-bound, then you have to
setup a default value for them...perhaps even use code to stuff in a value
of zero

me.txt_price = ccur(0)

The text boxes will be of type varient if they are un-bound.

Thanks - they are in fact unbound so I'll give that a try.
 

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

Top