select * from m02sales WHERE VOUCHERNUMBER='AR201109-0003' 主要的发票单
SELECT TOP 1 REFTYPE FROM m02salesDET WHERE VOUCHERNUMBER='AR201109-0003' AND SUBCODE='RICS' ORDER BY CODE 4个中的最主要的第一个产品信息
SELECT ITEMSNO FROM M21RENTALITEMS WHERE RENTITEMID='REIT201109-000001' 根据产品号 找到了他的序列号
UPDATE m02sales SET MAINDETREF ='????????????????????' WHERE VOUCHERNUMBER='AR201109-0003' update回去到主要的发票单的下脚
UPDATE m02sales SET MAINDETREF =(SELECT ITEMSNO FROM M21RENTALITEMS WHERE RENTITEMID=(SELECT TOP 1 REFTYPE FROM m02salesDET WHERE VOUCHERNUMBER='AR201109-0003' AND SUBCODE='RICS' ORDER BY CODE )) WHERE VOUCHERNUMBER='AR201109-0003'
cls00connection.update("UPDATE m02sales SET MAINDETREF =(SELECT ITEMSNO FROM M21RENTALITEMS WHERE RENTITEMID=(SELECT TOP 1 REFTYPE FROM m02salesDET WHERE VOUCHERNUMBER='" & cls00regional.string_filter(strVOUCHERNUMBER) & "'AND SUBCODE='RICS' ORDER BY CODE )) WHERE VOUCHERNUMBER='" & cls00regional.string_filter(strVOUCHERNUMBER) & "'")