老师您好!
我要自动生成表的编号列:规则是“wd-客户-20200721-编号2”,日期是今天日期。取编号2列的最大值加1。我的代码如下但出错。请指教!
'编号的自动生成
If e.DataCol.Name = "客户" Then
If e.DataRow.IsNull("客户") Then
e.DataRow("编号") = Nothing
Else
Dim bh As String = Format(Date.today(),"yyyyMMdd")
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("max(编号2)","[_Identify] <> "& e.DataRow("_Identify"))
messagebox.show(max)
If max > "" Then '如果存在最大编号
idx = CInt(max) + 1 '获得最大编号加1
Else
idx = 1
End If
e.DataRow("编号") = "wd-" & e.DataRow("客户") & "-" & bh & "-" & Format(idx,"000")
End If
End If