谢谢!我的表中增加了学科代码和用户ID两列,在表事件中执行的是:
Select e.DataCol.Name
Case "学科代码"
If e.DataRow.IsNull("学科代码") Then
e.DataRow("学科序号") = Nothing
Else
Dim lb As String = e.DataRow("学科代码")
If e.DataRow("学科序号").StartsWith(lb) = False '如果单据学科序号前缀不符
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(学科序号)","学科代码 = '" & lb & "'") '取得该学科代码的最大学
科序号
If max > "" Then '如果存在最大学科序号
idx = CInt(max.Substring(2,3)) + 1 '获得最大学科序号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("学科序号") = lb & Format(idx,"000")
End If
End If
End Select
我也想在“用户ID”按钮中直接写入代码,又怎么写?请指教!