|
做的一个查询,中间有段用DO UNTIL----LOOP 进行反复查询,直到查询不记录时就停止,请教停止的条件如何设?
Private Sub Command0_Click()
Dim L As Integer
Dim Qty1 As Integer
Dim Item As Integer
Dim Fdate As Date
Dim FWEEK As Integer
Item = 4375
Fdate = 2011 - 6 - 28
L = 0
Qty1 = 1
FWEEK = 1
Dim sql As String
sql = "insert into R (item,brand,part_no,QTY,leve,sid,fdate,fweek) select " & Item & " ,t_icitem.fname as brand,t_icitem.fshortnumber as part_no," & Qty1 & "," & L & ",right(10000+t_icitem.fitemid,4)," & Fdate & "," & FWEEK & " from DBO_t_icitem AS T_ICITEM where fitemid=" & Item
DoCmd.RunSQL sql
Dim n As Integer
Do Until ??(结束条件)
L = L + 1
sql = "insert into R (item,brand,part_no,QTY,leve,sid,fdate,fweek) select t_icitem.fitemid,t_icitem.fname,t_icitem.fshortnumber,icbomchild.fauxqty*" & Qty1 & " as Qty," & L & ",r.sid & ','& right(10000+t_icitem.fitemid,4), " & Fdate & " , " & FWEEK & " from DBO_t_icitem AS t_icitem,DBO_icbom AS ICBOM ,DBO_icbomchild AS ICBOMCHILD, r where R.leve = " & L - 1 & " And R.item = ICBOM.fitemid and icbom.FUSESTATUS=1072 and icbom.finterid=icbomchild.finterid and icbomchild.fitemid=t_icitem.fitemid"
DoCmd.RunSQL sql
Loop |
|