Recently, when I was working on a data center charging system, I encountered a form: Daily Statement.
Here, you need to determine the daily Recharge Amount, consumption amount, and refund amount. I calculated the data while loading the form. But how to calculate these problems. This is what I writeCodeOf:
Strtxtsql = "select sum (addmoney) from recharge_info where date = '" & A1 &"'"
Set mrca = executesql (strtxtsql, strmsgtext)
B = mrca. Fields (0)
Mrca. Close
I thought it was a very simple thing. During the operation, an error always occurred, and "invalid null value" was displayed ".
I copied the code in VB to SQL for query. The query is displayed as null.There is no Recharge Amount on the current day, and an error occurs when the null value is passed to B and the other number is added. Now I think of the isnull function, and the code is changed to the following:
Strtxtsql = "select sum (addmoney) from recharge_info where date = '" & A1 & "'" set mrca = executesql (strtxtsql, strmsgtext) If isnull (mrca. fields (0) then' if the displayed number is null, B = 0 else B = mrca. fields (0) end if mrca. close
This wayLet null value = 0The problem is easily solved.