突然间新导入的表不能自动形成编号了。其他表都好好的。
If e.DataTable.Name <> "数据表" AndAlso e.DataTable.Name <> "宣传员统计表" AndAlso e.DataTable.Name <> "一万五千人员核算表" Then
Select e.DataCol.Name
Case "第一次收益时间","人员姓名"
If e.DataRow.IsNull("第一次收益时间") OrElse e.DataRow.IsNull("人员姓名") Then
e.DataRow("人员编号") = Nothing
Else
Dim d As Date = e.DataRow("第一次收益时间")
Dim fd As Date = d
Dim ld As Date = fd.AddDays(1)
Dim bh As String = e.DataRow("人员姓名") & "-" & Format(d,"yyMMdd") & "-"
If e.DataRow("人员编号").StartsWith(bh) = False
Dim max As String
Dim idx As Integer
Dim flt As String
flt = "人员姓名 = '"& e.DataRow("人员姓名") & "' And 第一次收益时间 >= #" & fd & "# And 第一次收益时间 < #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")
max = e.DataTable.Compute("Max(人员编号)",flt)
If max > "" Then '如果存在最大单据编号
idx = CInt(max.Substring(bh.length)) + 1
Else
idx = 1
End If
e.DataRow("人员编号") = bh & Format(idx,"0000")
End If
End If
End Select
End If