vb的出库入库问题

来源:百度知道 编辑:UC知道 时间:2024/06/08 17:28:52
我在access中建了一个名为ypcaigou的数据库,该库中有入库表和出库表。现在想建一个库存表,内容为入库表中的产品减去已经出库的,如果某产品全部出库则在库存表中不显示该产品,该如何创建?
在入库表和出库表进行变动时,库存表能够同时更新数据。
请问mayorvb,库存表的中还需要数量这一field吗?

问题基本上理解。
其实很简单。
可以用一下方法来实现的。
首先要建立村库表。
dim rs as new adodb.recordset,rs2 as new adodb.recordset,rs3 as new adodb.recordset
rs.open "select * from [入库表]",conn,1,3
while not rs.eof
rs2.open "select * from [出库表] where id=" & rs("id"),conn,1,3
if rs.recordcount=0 then
rs3.open "select * from [村库表] where id=" & rs("id"),conn,1,3
if rs3.recordcount<>0 then
rs3.addnew
rs3("xxx1")=rs("xx1")
rs3("xxx2")=rs("xx2")
rs3("xxx3")=rs("xx3")
rs3("xxx4")=rs("xx4")
...
rs3.update
end if
rs3.close
end if
rs2.close
rs.movenext
wend
rs.close