标题: 请教andymark:以下这段代码如何合并? [打印本页] 作者: cyber-bobo 时间: 2006-10-21 05:47 标题: 请教andymark:以下这段代码如何合并? Private Sub 命令1_Click()
Dim Rs5 As New ADODB.Recordset
Dim Rst As New ADODB.Recordset
Dim Rs6 As New ADODB.Recordset
Dim Rst1 As New ADODB.Recordset
Dim Conn As New ADODB.Connection
Dim I As Integer
Dim J As Integer
Dim K As Integer
Set Conn = CurrentProject.Connection
Rst.Open "SELECT 产品ID,Count(产品ID) AS 产品ID之计数 FROM 临时表 GROUP BY 产品ID ORDER BY Count(产品ID) DESC , 产品ID", Conn, adOpenDynamic, adLockOptimistic
Do While Not Rst.EOF
I = I + 1
Rs5.Open "select * from 临时表 where 产品ID='" & Rst.Fields(0) & "' And 要求到货日期<# " & Year(Date) & "-" & Month(Date) & "-26# order by 产品ID", Conn, adOpenDynamic, adLockOptimistic
J = 0
Do While Not Rs5.EOF
J = J + 1
K = Int((I - 0.1) / 11) + 1
Rst1.Open "SELECT 产品ID,Count(产品ID) AS 产品ID之计数 FROM 临时表 GROUP BY 产品ID ORDER BY Count(产品ID) DESC , 产品ID", Conn, adOpenDynamic, adLockOptimistic
Do While Not Rst1.EOF
I = I + 1
Rs6.Open "select * from 临时表 where 产品ID='" & Rst1.Fields(0) & "' And 要求到货日期># " & Year(Date) & "-" & Month(Date) & "-25# order by 产品ID", Conn, adOpenDynamic, adLockOptimistic
J = 0
Do While Not Rs6.EOF
J = J + 1
K = Int((I - 0.1) / 11) + 1
Rs6.Fields("打印ID") = K
Rs6.MoveNext
If J Mod 6 = 0 Then
I = I + 1
Else
I = I
End If
Loop
Rs6.Close
Rst1.MoveNext
Loop
Set Rs5 = Nothing
Set Rst = Nothing
Set Rs6 = Nothing
Set Rst1 = Nothing
Set Conn = Nothing
Rst.Open "SELECT 产品ID,Count(产品ID) AS 产品ID之计数 FROM 临时表 where 要求到货日期<# " & Year(Date) & "-" & Month(Date) & "-26# GROUP BY 产品ID ORDER BY Count(产品ID) DESC , 产品ID", Conn, adOpenDynamic, adLockOptimistic作者: cyber-bobo 时间: 2006-10-21 07:49
想要的结果: