|
本人要创建一个“日资金帐余额查询”,以下是修改后的代码,但在运行时,系统提示“用于函数参数的个数不对,在查询表达式 `h([凭证名称].[发生日期`中。请帮助修改一下,XIEXIE.
'日资金帐余额
Public Function h(strCodeID As String, d As Date) As Currency
Set cn = Application.CurrentProject.Connection
Set rs = CreateObject("ADODB.Recordset")
'将材料代码和日期代入到查询条件中去
strSQL = "SELECT 凭证明细清单.凭证名称,Sum(([入库数量] - [出库数量])) AS 余额 " & _
"FROM 凭证明细清单 " & _
"WHERE 凭证明细清单.发生日期< #" & d & "# And 凭证名称 ='" & strCodeID & "' " & _
"GROUP BY 凭证明细清单.凭证名称;"
rs.Open strSQL, cn, 1
If rs.EOF = True Then Exit Function
h = rs("余额")
'MsgBox k
rs.Close
Set rs = Nothing
Set cn = Nothing
End Function
|
|