以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]老师,帮我看一下自动编号这段报错  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=160235)

--  作者:宇哥
--  发布时间:2021/1/25 18:48:00
--  [求助]老师,帮我看一下自动编号这段报错
重置列  报错

For Each dr As DataRow In DataTables("主表").DataRows

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 & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该类别代号的最大产品编号
                If max > "" Then \'如果存在最大产品编号

                    idx = CInt(max.Substring(max.Length -4,4)) + 1
                Else
                    idx = 1 \'否则顺序号等于1
                End If
                e.DataRow("编号") = lb & "-" & Format(idx,"0000")
            End If
        End If

End Select


哪的问题呀?看的眼睛都花掉了
[此贴子已经被作者于2021/1/25 18:54:49编辑过]

--  作者:有点蓝
--  发布时间:2021/1/25 19:55:00
--  
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(编号)","英文简写 = \'" & e.DataRow("英文简写") & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该类别代号的最大产品编号
                If max > "" Then \'如果存在最大产品编号
                    idx = CInt(max.Substring(max.Length -4,4)) + 1
                Else
                    idx = 1 \'否则顺序号等于1
                End If
                e.DataRow("编号") = lb & Format(idx,"0000")
            End If
        End If

End Select

--  作者:宇哥
--  发布时间:2021/1/25 23:04:00
--  
蓝老师,再费心指导一下,上面代码复制过来不执行。刚接触1个月,别嫌我啊

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(编号)","英文简写 = \'" & e.DataRow("英文简写") & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该类别代号的最大产品编号
                If max > "" Then \'如果存在最大产品编号
                    idx = CInt(max.Substring(max.Length -4,4)) + 1
                Else
                    idx = 1 \'否则顺序号等于1
                End If
                e.DataRow("编号") = lb & Format(idx,"0000")
            End If
        End If

End Select

此主题相关图片如下:~~ko@vk3q}`v4`mntand7.png
按此在新窗口浏览图片


--  作者:宇哥
--  发布时间:2021/1/25 23:11:00
--  
顺便还有一个分区面板代码问题请教,谢谢
图片点击可在新窗口打开查看此主题相关图片如下:o%~japq1%0on(3r$7e2fz5p.png
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2021/1/25 23:15:00
--  
回3楼,英文简写列的表达式是什么?

回4楼、按钮里设置SplitterDistance:http://www.foxtable.com/webhelp/topics/0819.htm

--  作者:宇哥
--  发布时间:2021/1/26 9:51:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:gif 2021-01-26 09-46-37.gif
图片点击可在新窗口打开查看
 表达式:Parent(关联设备型号).英文简写
[此贴子已经被作者于2021/1/26 9:51:36编辑过]

--  作者:有点蓝
--  发布时间:2021/1/26 10:16:00
--  
通过什么列和父表关联的?改为关联列

Select e.DataCol.Name
    Case "关联列"
        If e.DataRow.IsNull("关联列") Then

--  作者:宇哥
--  发布时间:2021/1/26 11:31:00
--  
关联的是【设备型号表】的【英文简写】列:

Dim dt As DataTable = DataTables("设备型号表")
Dim dc As DataCol = dt.DataCols("英文简写")
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(编号)","英文简写 = \'" & e.DataRow("英文简写") & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该类别代号的最大产品编号
                If max > "" Then \'如果存在最大产品编号
                    idx = CInt(max.Substring(max.Length -4,4)) + 1
                Else
                    idx = 1 \'否则顺序号等于1
                End If
                e.DataRow("编号") = lb & Format(idx,"0000")
            End If
        End If

--  作者:宇哥
--  发布时间:2021/1/26 11:32:00
--  
 兰老师,要不要我上传实例,您看一下呢


--  作者:有点蓝
--  发布时间:2021/1/26 11:42:00
--  
这里看到的关联列:http://www.foxtable.com/webhelp/topics/0091.htm