A very strange incident... and strange question.
Well I was working on a MS-Access 2003 project that has a bit of VB code that executes once a certain text box loses focus.
When it loses the focus it calculates a couple of lines of code. Everything worked fine.
Now for some reason it seems to crash, when I debug it, it goes to a line where the following happens
'cPrice get's a value on the form e.g. R150.00
'iWeight get's a value from the form as well e.g. 5t
tTax = cPrice / iWeight
But it keeps stalling there, VB auto casts it's types if I am not mistaken, so anyone any ideas why this keeps failing?
[580 byte] By [
Heinz09] at [2007-12-28]
What types are cprice, iweight and ttax? if they are decimal, the division can cause exceptions for overflow or division by zero.
For integers, the division itself may not throw an exception, but the assignment to ttax can.
cprice is currency, iweight is integer, ttax is textbox
everything worked fine until a day or 2 ago when it started throwing the exception
Couple more questions - is the code VBA then?
Also, while debugging, can you check what the values on cprice and iweight are?
I checked the values, everything gets assigned.
It seems the moment the cPrice gets assigned R 519.99 and multiplied by any number, it keeps bombing out.
Once I formatted the cPrice to number instead of currency everything worked fine.
It seems that VBA just is not too friendly when it comes to auto casting of types.
Thanks for all the helpful input anyways.
Kind Regards
Heinz