data type conversion error... (1 Viewer)

mfuada

Registered User.
Local time
Today, 21:46
Joined
Feb 4, 2009
Messages
63
hi i want to ask u guys..
coupon_bbtxt = Format(listbuyback.Column(5), "0.00000%") --> my textbox that get its' value from a listbox

Set buyadd_db = CurrentDb.OpenRecordset("buyback")
buyadd_db.AddNew
buyadd_db!coupon_bb = Me!coupon_bbtxt
buyadd_db.Update

the field "coupon_bb" has percent format with decimal places set to 5
but when i'm updating the table it show me the error message "Data type conversion error"
could anyone help me?
thx
 

Rabbie

Super Moderator
Local time
Today, 15:46
Joined
Jul 10, 2007
Messages
5,906
Have you set Option Explicit in your code module. If not then do so. It will then trap any errors caused by using an undeclared variable.

Try changing this line

coupon_bbtxt = Format(listbuyback.Column(5), "0.00000%")

to

Me!coupon_bbtxt = Format(listbuyback.Column(5), "0.00000%")
 

mfuada

Registered User.
Local time
Today, 21:46
Joined
Feb 4, 2009
Messages
63
I have change my line to :
Me!coupon_bbtxt = Format(daftarbuyback.Column(5), "0.00000%")
but still get the error message "Data type conversion error"......
but when i'm removing the "format" and the "0.00000%" the code working just fine....
 

boblarson

Smeghead
Local time
Today, 07:46
Joined
Jan 12, 2001
Messages
32,059
When you use format it is coercing it to be a STRING (TEXT) instead of a number.

You can't include the % sign when putting it back to a number field.
 

mfuada

Registered User.
Local time
Today, 21:46
Joined
Feb 4, 2009
Messages
63
my first intention in using "format" is because if i just wrote this code:.
coupon_bbtxt = listbuyback.Column(5)
and suppose the listbuyback in column(5) has the value of 15,50%

then the coupon_bbtxt will return the value "0,155" although i have change the format to percent and decimal to 5 of in the coupon_bbtxt's property

And since i want the textbox to display the value with percent (similar tothe listbox), i use "format" to display the percent....
so is there any suggestion?

ps: in the listbox the column(5) keep displaying the percent value with 2 decimal places although in the table that the listbox get the value,the value is a percent with 5 decimal places behind zero? :confused:

thx
 

Users who are viewing this thread

Top Bottom