以文本方式查看主题

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

--  作者:peterx
--  发布时间:2015/2/12 9:19:00
--  求助:查询时,查无数据时,如何不显示为空表,而保持当前表?
求助:查询时,查无数据时,如何不显示为空表,而保持当前表?谢谢
代码如下:

Dim year As WinForm.comboBox = e.Form.Controls("year")
Dim no As WinForm.textBox = e.Form.Controls("No")
If no.text.length <>3 Then
    MessageBox.show("总序号应是三位数,现在输入的位数是:" & no.text.length & "位数!")
Else
    Tables("购置申请管理").Filter="购置申请编号分解_年度 = \'" & year.Text & "\' and 购置申请编号分解_总序号 = \'" & no.text & "\'"
End If

--  作者:有点甜
--  发布时间:2015/2/12 9:21:00
--  
Dim filter As String = "购置申请编号分解_年度 = \'" & year.Text & "\' and 购置申请编号分解_总序号 = \'" & no.text & "\'"
If DataTables("购置申请管理").Find(filter) IsNot Nothing Then
    Tables("购置申请管理").Filter=filter
End If

--  作者:Bin
--  发布时间:2015/2/12 9:22:00
--  
先Compute 一下 http://www.foxtable.com/help/topics/0393.htm

获取到符合这个条件的行数.大于0 再执行筛选

if datatables("X").Compute("count(_Identify)","购置申请编号分解_年度 = \'" & year.Text & "\' and 购置申请编号分解_总序号 = \'" & no.text & "\'") > 0 then
   Tables("购置申请管理").Filter="购置申请编号分解_年度 = \'" & year.Text & "\' and 购置申请编号分解_总序号 = \'" & no.text & "\'"

end if

--  作者:peterx
--  发布时间:2015/2/12 9:28:00
--  
谢谢。