If e.DataCol.Name = "中标日期" Then
If e.DataRow.IsNull("中标日期") Then
e.DataRow("档案编号") = Nothing
e.DataRow("年份") = Nothing '如果为空,则清除
Else
e.DataRow("年份") = Format(e.DataRow("中标日期"),"yyyy")
Dim bh As String = "P" & Format(e.DataRow("中标日期"),"yy") '取得编号的8位前缀
Dim max As String
Dim idx As Integer
max = e.DataTable.SQLCompute("Max(档案编号)","档案编号 like '" & bh & "%' And [_Identify] <> " & e.DataRow("_Identify")) '取得该天的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(bh.length)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("档案编号") = bh & Format(idx,"000")
End If
End If
用 max = e.DataTable.sqlCompute("Max(档案编号)","档案编号 like '" & bh & "%' And [_Identify] <> '" & e.DataRow("_Identify") & "'") 也不行
改成max = e.DataTable.SQLCompute后,错误
.NET Framework 版本:2.0.50727.8806
Foxtable 版本:2018.10.9.1
错误所在事件:
详细错误信息:
“991”附近有语法错误。
991是主键值
msgbox(max) 为空值
[此贴子已经被作者于2019/7/23 13:31:29编辑过]