以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  自动编号问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=192405)

--  作者:13315253800
--  发布时间:2024/6/21 18:57:00
--  自动编号问题
蓝老师您好!我用下面的代码自动编号,序号不自动增加,请指导
\'序号自动编号
Select e.DataCol.Name
    Case "分类", "分组"
        If e.DataRow.IsNull("分类") OrElse e.DataRow.IsNull("分组") Then
            e.DataRow("序号") = Nothing
        Else
            Dim bh As String = e.DataRow("分类") & e.DataRow("分组") \'生成序号的前缀           
            If e.DataRow("序号").StartsWith(bh) = False Then\'如果单据编号前缀不符
                Dim max As String
                Dim idx As Integer
                Dim flt As String
                flt = "序号 = \'" & e.DataRow("分类") & "\' And  \'" & e.DataRow("分组") & "\' And [_Identify] <> " & e.DataRow("_Identify")
                max = e.DataTable.Compute("Max(序号)", flt) \'取得最大单据序号
                If max > "" Then \'如果存在最大编号
                 \'   idx = CInt(max.Substring(6, 2)) + 1 \'获得最大编号的后2位顺序号,并加1
                    idx = CInt(max.Substring(max.length - 2)) + 1 \'获得最大编号的后三位顺序号,并加1
                Else
                    idx = 1 \'否则顺序号等于1
                End If
                e.DataRow("序号") = bh & Format(idx, "00")
            End If
        End If
End Select

--  作者:wyz20130512
--  发布时间:2024/6/21 20:09:00
--  
上传实例看看。


--  作者:有点蓝
--  发布时间:2024/6/22 8:43:00
--  
flt = "序号 = \'" & e.DataRow("分类") & "\' And  \'" & e.DataRow("分组") & "\' And [_Identify] <> " & e.DataRow("_Identify")
改为
flt = "分类 = \'" & e.DataRow("分类") & "\' And  分组=\'" & e.DataRow("分组") & "\' And [_Identify] <> " & e.DataRow("_Identify")

--  作者:13315253800
--  发布时间:2024/6/22 8:52:00
--  
.NET Framework 版本:4.0.30319.36543
Foxtable 版本:2022.8.18.1
错误所在事件:表,双代码自动编号,DataColChanged
详细错误信息:
Exception has been thrown by the target of an invocation.
Syntax error: Missing operand after \'And  分组\' operator.


--  作者:13315253800
--  发布时间:2024/6/22 8:59:00
--  
上传实例,敬请指导
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:自动编号.foxdb


--  作者:有点蓝
--  发布时间:2024/6/22 9:13:00
--  
别人给的代码尽量直接复制。手输的要注意全角和半角的区别,【And  分组】之间是半角的空格,不是全角的空格