If e.DataCol.Name = "托运日期" Then
If e.DataRow.IsNull("托运日期") Then
e.DataRow("货单编号") = Nothing
Else
Dim bh As String = Format(e.DataRow("托运日期"),"yyyyMMdd") & "-"
If e.DataRow("货单编号").StartsWith(bh) = False
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(货单编号)","托运日期 = #" & e.DataRow("托运日期") & "# And [_Identify] <> " & e.DataRow("_Identify"))
If max > "" Then
idx = CInt(max.Substring(9,3)) + 1
idx = 1
End If
e.DataRow("货单编号") = bh & Format(idx,"000")
End If
End If
End If
[此贴子已经被作者于2014-4-27 3:37:58编辑过]