|
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
Rs5.Fields("打印ID") = K
Rs5.MoveNext
If J Mod 6 = 0 Then
I = I + 1
Else
I = I
End If
Loop
Rs5.Close
Rst.MoveNext
Loop
'----------------------------------------------
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
End Sub
实际上是以本月25日为分界,分开两部份来排序,但排序号要连续不归零。 |
|