以文本方式查看主题

-  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=146599)

--  作者:chh2321
--  发布时间:2020/2/27 12:50:00
--  [求助]关于微整数值不显示的问题

请教老师,A表的微整数值字段为0时,我想通过DataColChanged事件让B表相关微整数值字段也显示为0,但是B表却显示为“”,该如何解决?
[此贴子已经被作者于2020/2/27 12:55:32编辑过]

--  作者:有点蓝
--  发布时间:2020/2/27 14:26:00
--  
写了什么代码,贴出来
--  作者:chh2321
--  发布时间:2020/2/27 14:53:00
--  
Dim dr As DataRow
dr = DataTables("表B").Find("第一列 =\'" & e.DataRow("第一列") & "\' and 第二列 =#" & e.DataRow("第二列") & "#")

If dr IsNot Nothing Then
    If e.DataRow("第三列") = Nothing Then
        dr("第三列") = Nothing
    ElseIf e.DataRow("第三列") <> Nothing Then
        dr("第三列") = e.DataRow("第三列")
    End If
ElseIf dr Is Nothing Then
    Dim t = Tables("表B").AddNew
    t("第一列") = e.DataRow("第一列")
    t("第二列") = e.DataRow("第二列")
    t("第三列") = e.DataRow("第三列")
End If
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:示例.table



--  作者:有点蓝
--  发布时间:2020/2/27 15:15:00
--  
问题1,先看看:http://www.foxtable.com/webhelp/topics/1522.htm

Select Case e.DataCol.Name
    Case  "第一列","第二列"
        If e.DataRow.IsNull("第一列") = False AndAlso e.DataRow.IsNull("第二列") = False  Then
            Dim dr As DataRow
            dr = DataTables("表B").Find("第一列 =\'" & e.DataRow("第一列") & "\' and 第二列 =#" & e.DataRow("第二列") & "#")
            
            If dr Is Nothing Then
                dr = DataTables("表B").AddNew
                dr("第一列") = e.DataRow("第一列")
                dr("第二列") = e.DataRow("第二列")
            End If
            dr("第三列") = e.DataRow("第三列")
        End If
End Select

--  作者:chh2321
--  发布时间:2020/2/27 15:34:00
--  

谢谢老师,把上述代码改成:
Select Case e.DataCol.Name
    Case  "第一列","第二列","第三列"
        If e.DataRow.IsNull("第一列") = False AndAlso e.DataRow.IsNull("第二列") = False  Then
            Dim dr As DataRow
            dr = DataTables("表B").Find("第一列 =\'" & e.DataRow("第一列") & "\' and 第二列 =#" & e.DataRow("第二列") & "#")
            
            If dr Is Nothing Then
                dr = DataTables("表B").AddNew
                dr("第一列") = e.DataRow("第一列")
                dr("第二列") = e.DataRow("第二列")
            End If
            dr("第三列") = e.DataRow("第三列")
        End If
End Select

问题解决了。

但如果把A表的第三列数字删掉后,B表的第三列会显示为0,这时能否让B表第三列显示为“”;只有当A表第三列输入0时,B表第三列才显示为0
[此贴子已经被作者于2020/2/27 15:35:06编辑过]

--  作者:有点蓝
--  发布时间:2020/2/27 16:00:00
--  
if e.DataRow.isnull("第三列")
dr("第三列") = nothing
else
dr("第三列") = e.DataRow("第三列")
endif

--  作者:chh2321
--  发布时间:2020/2/27 16:07:00
--  

谢谢老师!