f 是一个自定义函数,原型如下,作用是为了计算当前日期的余额,其实这个实例也可以直接在窗体的Text控件里用DSUM函数实现的:
Public Function f(d As Date) As Currency
Dim a As Currency
Dim b As Currency
a = Nz(DSum("[银行存款]![存入]", "[银行存款]", "[日期] <= # " & d & "#"))
b = Nz(DSum("[银行存款]![提款]", "[银行存款]", "[日期] <= # " & d & "#"))
f = a - b
End Function