Dim m As Integer = d.Month
Dim d1 As Date = new Date(y,m,1)
Dim d2 As Date = new Date(y,m,Date.DaysInMonth(y,m))
Dim s1 As String = "品名编号 = '" & dr("品名编号") & "' And 日期 >= #" & d1 & "# And 日期 <= #" & d2 & "# And 部门 Like ' 入库*'"
Dim s2 As String = "品名编号 = '" & dr("品名编号") & "' And 日期 >= #" & d1 & "# And 日期 <= #" & d2 & "# And 部门 Like ' 出库*'"
Dim s3 As String = "品名编号 = '" & dr("品名编号") & "' And 日期 >= #" & d1 & "# And 日期 <= #" & d2 & "# '" dr("账面库房数量_本月入库") = DataTables("出入库").Compute("Sum(核算数量)",s1)
dr("账面库房数量_本月出库") = DataTables("出入库").Compute("Sum(核算数量)",s2)
dr("结算_结算数量") = dr("结算_库外领用累计")-DataTables("盘点").Compute("Sum(实盘数量_本月库外完好)",s3)
重新整理了一下楼主的代码,看不出问题,楼主可以上传文件看看