产品出仓入仓可以通过调拨的方式来处理,需要一个调拨明细表,调拨单单头表和一个库存表,调拨明细表含有字段:货号,单号,单价,数量,由仓号,至仓号;库存表含有的字段:货号,单价,数量,仓号;调拨单单头表含有的字段:单号,从仓号,至仓号等,实现方法:先判断库存表里边有无调拨表里边对应单号的出入库数据,若有则更新对应库存,若无则需插入调拨表中对应单号的不存在于库存表中的数据,再更新对应仓号的库存.下面是我做系统时写的一段代码:TXNRACK是库存表,STKLEDGER是调拨明细表,STKMOVE是调拨单的单头表
DoCmd.RunSQL "insert into txnrack(plucode,warehouse,price) select plucode,torack,price from stkledger where not exists(select * from txnrack where txnrack.plucode=stkledger.plucode and txnrack.warehouse=stkledger.torack) and number='" & Me.NUMBER & "'"
DoCmd.RunSQL "insert into txnrack(plucode,warehouse,price) select plucode,fromrack,price from stkledger where not exists(select * from txnrack where txnrack.plucode=stkledger.plucode and txnrack.warehouse=stkledger.fromrack) and number='" & Me.NUMBER & "'"
DoCmd.RunSQL "update stkledger,stkmove set stkledger.txndate=stkmove.txndate where stkmove.number=stkledger.number"
DoCmd.RunSQL "UPDATE STKLEDGER,STKMOVE SET STKLEDGER.TORACK=STKMOVE.TW,STKLEDGER.FROMRACK=STKMOVE.FW WHERE STKMOVE.NUMBER=STKLEDGER.NUMBER"
DoCmd.RunSQL "update txnrack,stkledger set txnrack.qty=nz(txnrack.qty,0)+stkledger.qty where txnrack.plucode=stkledger.plucode and txnrack.warehouse=stkledger.torack and stkledger.number='" & Me.NUMBER & "'"
DoCmd.RunSQL "update txnrack,stkledger set txnrack.qty=nz(txnrack.qty,0)-stkledger.qty where txnrack.plucode=stkledger.plucode and txnrack.warehouse=stkledger.fromrack and stkledger.number='" & Me.NUMBER & "'"
DoCmd.RunSQL "update stkledger set apv=1 where number='" & Me.NUMBER & "'"