细节自己调整
filter="Select i1.ITEM_CODE,i1.ITEM_NAME,i1.ITEM_SPECIFICATION,m1.DOC_NO,m1.DOC_DATE,m1.STATUS,m1.PLAN_QTY,substring(m1.DEMAND_NO,1,17) order_no,m1.COMPLETED_QTY,m1.ACTUAL_START_DATE,m1.ACTUAL_COMPLETE_DATE"
filter=filter & " FR OM {MO} As m1 left join {ITEM} As i1 on m1.ITEM_ID=i1.ITEM_BUSINESS_ID"
filter=filter & " WHERE i1.[ITEM_CODE]='"& Vars("find01") & "' And substring(m1.[DOC_NO],1,4) In ('" & Vars("find00").replace(",","','") & "') And m1.[STATUS] In ( " & g_stat & " ) And m1.[DOC_DATE] between '" & Date1 & "' and '" & Date2 & "' ORDER BY m1.DOC_DATE desc" '取所有条件
合成的filter,msgbox弹出一下,看是否正确,在sql测试窗口测试合成的语句