参考 :http://www.foxtable.com/help/topics/2403.htm
代码放到按钮事件中,改改,类似:
Dim dr As DataRow = DataTables("订单").AddNew()
Dim max As String
Dim idx As Integer
max = DataTables("订单").Compute("Max(编号)"," [_Identify] <> " & e.DataRow("_Identify")) '取得该类别的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(2,3)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
dr("编号") = Format(Date.Today,"yyyyMMdd") & Format(idx,"000")