Office中国论坛/Access中国论坛
标题:
快速计算库存原始代码
[打印本页]
作者:
李玉文
时间:
2004-12-5 22:17
标题:
快速计算库存原始代码
下面的上期数据是根据月进行计算的,我想改成日,请高手帮帮忙啦
Public Function k(strCodeID As String, lngY As Long, lngM As Long) As Long
Dim strSQL As String
Dim rs As Object
Dim cn As Object
Set cn = Application.CurrentProject.Connection
Set rs = CreateObject("ADODB.Recordset")
'将材料代码和日期代入到查询条件中去
strSQL = "SELECT 原料.产品编号, Sum(([进货]-[出货])) AS 库存 " & _
"FROM 原料 " & _
"WHERE 原料.[rq] < #" & lngM & "/1" & "/" & lngY & "# And 产品编号 ='" & strCodeID & "' " & _
"GROUP BY 原料.产品编号;"
rs.Open strSQL, cn, 1
If rs.EOF = True Then Exit Function
k = rs("库存")
'MsgBox k
rs.Close
Set rs = Nothing
Set cn = Nothing
End Function
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3