|
本帖最后由 roych 于 2015-6-3 15:53 编辑
- Function SplitBox()
- Dim rst1 As New ADODB.Recordset
- Dim rst2 As New ADODB.Recordset
- Dim fld As ADODB.Field
- Dim i As Long
- Dim lngBoxNum As Long
- '打开记录集
- rst1.Open "表1", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
- rst2.Open "表2", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
- '拍的是否达到文件末端
- Do Until rst1.EOF
- '判断是否整箱
- If rst1("订单需求量") Mod rst1("装箱基数") = 0 Then
- lngBoxNum = rst1("订单需求量") / rst1("装箱基数")
- Else
- lngBoxNum = Int(rst1("订单需求量") / rst1("装箱基数")) + 1
- End If
- '字段不多,这里就直接编码了。
- For i = 1 To lngBoxNum
- '新增记录
- rst2.AddNew
- rst2("品番") = rst1("品番")
- rst2("生产任务单号") = rst1("生产任务单号")
- rst2("订单需求量") = rst1("订单需求量")
- rst2("装箱基数") = rst1("装箱基数")
- rst2("交货期") = rst1("交货期")
- rst2("箱号") = i
- rst2("总箱数") = lngBoxNum
- '更新记录
- rst2.Update
- Next
- '移动记录集光标
- rst1.MoveNext
- Loop
- End Function
复制代码
样表.rar
(21 KB, 下载次数: 46)
|
|