以文本方式查看主题

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

--  作者:15666282205
--  发布时间:2019/11/16 15:57:00
--  列为空值则隐藏,不显示
老师,如果列的内容为空,就隐藏,不显示,如何编写代码?
--  作者:有点蓝
--  发布时间:2019/11/16 16:08:00
--  
整列没有数据就隐藏?

if tables(“表A”).compute("count(第一列)","第一列 is not null") = 0 then
tables(“表A”).cols("第一列").visible = false
end if

--  作者:15666282205
--  发布时间:2019/11/16 16:25:00
--  
是整列没有数据就隐藏,共有200列,需要逐列判断,还请您再优化一下代码。
--  作者:有点蓝
--  发布时间:2019/11/16 16:53:00
--  
遍历所有列,参考:http://www.foxtable.com/webhelp/topics/0561.htm
--  作者:15666282205
--  发布时间:2019/11/18 14:37:00
--  
老师,我看了帮助,可是还是不会遍历,只会这样写代码,这三列按预期隐藏了,其他还有接近200列要判断,还请您抽空指点一二,多谢了。
If Tables("累计考勤表").compute("count(D1_夜班)","D1_夜班 is not null") = 0 Then
    Tables("累计考勤表").cols("D1_夜班").visible = False
End If
If Tables("累计考勤表").compute("count(D2_夜班)","D1_夜班 is not null") = 0 Then
    Tables("累计考勤表").cols("D2_夜班").visible = False
End If
If Tables("累计考勤表").compute("count(D3_夜班)","D1_夜班 is not null") = 0 Then
    Tables("累计考勤表").cols("D3_夜班").visible = False
End If


--  作者:有点蓝
--  发布时间:2019/11/18 14:50:00
--  
For Each cl As Col In Tables("累计考勤表").Cols
    Output.Show(cl.Name)
cl.visible = False
Next

--  作者:15666282205
--  发布时间:2019/11/18 16:26:00
--  
老师,这段代码我从帮助里也看到了,怎么和5楼的判断结合起来呢?
--  作者:有点蓝
--  发布时间:2019/11/18 16:29:00
--  
For Each cl As Col In Tables("累计考勤表").Cols
    If Tables("累计考勤表").compute("count(_Identify)",cl.name & " is not null") = 0 Then cl.visible = False
Next

--  作者:15666282205
--  发布时间:2019/11/18 17:06:00
--  
老师,8楼的不行,运行后所有列都不先显示了。2楼和5楼的行,就是有点笨。
--  作者:有点蓝
--  发布时间:2019/11/18 17:13:00
--  
自己排除不需要控制的列

For Each cl As Col In Tables("累计考勤表").Cols
if cl.name <> "第一列"
    If Tables("累计考勤表").compute("count(_Identify)",cl.name & " is not null") = 0 Then cl.visible = False
endif
Next