mfuada
02-12-2009, 06:34 PM
Hi
this is my script :
Private Sub Command45_Click()
tot_valtxt.Value = currency_ratetxt.Value * Listbox12.Value
End Sub
if i click the button, the textbox tot_valtxt.Value is blank...
the listbox12.value is a listbox with a row source from a query.
So what i would like to do is to add a query and data in the textbox form...
and i've changed all the format to currency including data in the table...
could anybody help?
thx
ACMAIN_CHM
02-13-2009, 08:05 AM
try this
Private Sub Command45_Click()
tot_valtxt.Value = val(currency_ratetxt.Value) * val(Listbox12.Value)
End Sub
mfuada
02-15-2009, 04:01 PM
nope it's not working, i got a message "invalid use of null".....
ByteMyzer
02-15-2009, 04:39 PM
Try:
Private Sub Command45_Click()
tot_valtxt.Value = Nz(currency_ratetxt.Value, 0) * Nz(Listbox12.Value, 0)
End Sub
mfuada
02-15-2009, 05:13 PM
Works perfectly... thank you.. btw could you tell me whyis my code doesn't working, so i can learn from my mistake?
boblarson
02-15-2009, 05:34 PM
Works perfectly... thank you.. btw could you tell me whyis my code doesn't working, so i can learn from my mistake?
You needed to use the NZ function to deal with NULL values as you can't multiply a null to get an answer. So, you would get the "invalid use of null" error. Using the NZ function, as he had written it, substitutes a zero (0) in place if there is a null.
mfuada
02-15-2009, 08:07 PM
sorry guys.. but after i restarted my project the tot_valtxt.value return with "0" value...
i assumed that because access did not read value of listbox12 because the listbox12 has the value from row source that originally came from a query...
so is there any suggestion?
ps:it works fine when i first tried the NZ function:(
You say that the code provided is failing, but maybe that's because the user hasn't selected a row of the listbox as yet?
Has the user selected a row, or not? If not, the calculation will fail.
mfuada
02-16-2009, 01:57 AM
you're so right... thanks... :)