Tables("打印产品.生产编码").AddNew() '增加行
'光标定位在新增加行
If Tables("打印产品.生产编码").Current IsNot Nothing Then
Tables("打印产品.生产编码").Select(Tables("打印产品.生产编码").Current.Index,Tables("打印产品.生产编码").Cols("产品类别").Index)
Tables("打印产品.生产编码").StartEditing
End If
Dim n As Integer = 5
If InputValue(n, "行数", "增加多少行?") Then
DataTables("生产编码").StopRedraw
systemready = False
Dim max As String
Dim idx As Integer
max = Tables("打印产品.生产编码").Compute("Max(日编号)","日期 = #" & Tables("打印产品").Current("日期") & "#") '取得该天的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(9,3)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
For i As Integer = 1 To n
Dim nr = Tables("打印产品.生产编码").AddNew
nr("编号")= Format(Tables("打印产品").Current("日期"),"yyyyMMdd") '日期转换字符
nr("日编号")= nr("编号") & "-" & format(idx + i - 1, "000")
Next
systemready = True
DataTables("生产编码").ResumeRedraw
DataTables("生产编码").DataCols("二维码编号").Expression = "IIF([分支器] Like '空%',[姓名]+':'+[类别代码]+'-'+[日编号],[姓名]+':'+[分支器]+[类别代码]+'-'+[日编号])"
End If