|
楼主 |
发表于 2009-8-20 08:41:01
|
显示全部楼层
With rsPubs
.ActiveConnection = cnPubs
.CursorType = adOpenForwardOnly
.LockType = adLockReadOnly
.Open "select a.socode,b.ccuscode,a.duedate,a.invcode,a.invname,a.comunitname,'',a.planqty,a.CrdQty,isnull((select sum(c.iquantity) from CurrentStock as c where c.cwhcode<>'08'and c.cinvcode=a.invcode group by c.cinvcode),0) ," & _
"ISNULL(isnull((select sum(PO.iquantity-isnull(PO.iarrqty,0)) from po_podetails as PO " & _
"where PO.cbcloser is null and PO.iquantity >isnull(PO.iarrqty,0) and PO.cinvcode=A.[invcode] group by PO.cinvcode)," & _
"(select sum(o.iquantity-isnull(o.iarrqty,0)) from om_modetails as o " & _
"where o.cbcloser is null and o.iquantity >isnull(o.iarrqty,0) and o.cinvcode=A.[invcode] group by o.cinvcode)),0)" & _
"from v_mps_netdemandsaleandexorder as b,V_mps_netdemand as a " & _
"where a.socode >='" + str_CAB001_Begin + " 'AND a.socode <='" + str_CAB001_End + " '" & _
"AND b.csocode =a.socode AND b.irowno= a.soseq " & _
" order by a.socode,a.invcode"
Sheet38.Range("A3").CopyFromRecordset rsPubs
.Close
.ActiveConnection = cnPubs
.CursorType = adOpenForwardOnly
.LockType = adLockReadOnly
.Open "select m.invcode,sum(m.qty-m.issqty) from v_mom_moallocate_rpt as m inner join v_mom_orderdetail as b on M.MoDId=b.modid where b.status<>4 and (M.qty-M.issqty)>=0 group by M.invcode order by m.invcode"
Sheet38.Range("o3").CopyFromRecordset rsPubs
.Close
End With |
|