以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]选择逻辑列自动编号  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=75735)

--  作者:seal51
--  发布时间:2015/10/13 22:58:00
--  [求助]选择逻辑列自动编号


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20151013225558.png
图片点击可在新窗口打开查看

1.如果产品图号为空, 勾选有图否, 生成一个图号, 不需要这个图号, 手工删除,手工删除后有图否勾选自动取消
2.如果产品图号不为空, 或者手工输入图号后, 无论勾选与否, 图号不能添加自动编号

 

下面的代码如何更改

 

If e.DataCol.Name = "有图否" AndAlso e.DataRow("有图否") = True Then
    If e.DataRow("产品图号") IsNot Nothing = False Then
        e.cancel = True
    Else
        e.DataRow("产品图号") = "SMP" & Format(e.DataRow("_Identify"), "000000")
    End If
Else
    If e.DataRow("产品图号") IsNot Nothing = True Then
        e.DataRow("有图否") = False
        e.cancel = True
    End If
End If

[此贴子已经被作者于2015/10/13 23:06:36编辑过]

--  作者:大红袍
--  发布时间:2015/10/13 23:10:00
--  

If e.DataCol.Name = "产品图号" Then
   
    If e.NewValue = Nothing Then
       
        e.DataRow("有图否") = False
       
    Else
       
        e.DataRow("有图否") = True
       
    End If
   
End If

If e.DataCol.Name = "有图否" AndAlso e.DataRow("有图否") = True Then
    If e.DataRow("产品图号") Is Nothing  Then
        e.DataRow("产品图号") = "SMP" & Format(e.DataRow("_Identify"), "000000")
    End If
End If


--  作者:seal51
--  发布时间:2015/10/13 23:20:00
--  

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:图号生成2.foxdb

代码不对, 勾选没有反应,老师打开附件测试看看


--  作者:Hyphen
--  发布时间:2015/10/14 8:34:00
--  

If e.DataCol.Name = "产品图号" Then
    If e.NewValue = Nothing Then
        e.DataRow("有图否") = False
    Else
        e.DataRow("有图否") = True
    End If
End If

If e.DataCol.Name = "有图否" AndAlso e.DataRow("有图否") = True Then
    If e.DataRow.IsNull("产品图号")  Then
        e.DataRow("产品图号") = "SMP" & Format(e.DataRow("_Identify"), "000000")
    End If
End If


--  作者:seal51
--  发布时间:2015/10/14 9:31:00
--  

谢谢4楼的回复, 不过未达到目的,结果一样


--  作者:大红袍
--  发布时间:2015/10/14 10:03:00
--  
代码都没有问题。
--  作者:seal51
--  发布时间:2015/10/14 10:11:00
--  

比如最后一个PID000019, 我手工删除图号SMP00019, 手工输入一个特殊图号AAA, 然后再勾选有图否, 图号有变成了SMP00019, 我的要求是不能更改手工输入的图号


--  作者:大红袍
--  发布时间:2015/10/14 10:24:00
--  

4楼代码没问题啊

 

If e.DataCol.Name = "产品图号" Then
    If e.NewValue = Nothing Then
        e.DataRow("有图否") = False
    Else
        e.DataRow("有图否") = True
    End If
End If

If e.DataCol.Name = "有图否" AndAlso e.DataRow("有图否") = True Then
    If e.DataRow.IsNull("产品图号")  Then
        e.DataRow("产品图号") = "SMP" & Format(e.DataRow("_Identify"), "000000")
    End If
End If