以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  提示列名(物供号、类别、厂号、客款号)无效  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=119243)

--  作者:yetle
--  发布时间:2018/5/21 14:05:00
--  提示列名(物供号、类别、厂号、客款号)无效
提示列名(物供号、类别、厂号、客款号)无效,这样写不对吗?
Dim stade As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker1")
Dim Endde As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker2")
Dim cs01 As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim cs02 As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim cs03 As WinForm.ComboBox = e.Form.Controls("ComboBox3")
Dim cs04 As WinForm.ComboBox = e.Form.Controls("ComboBox4")

Dim dt As DataTable=DataTables("dbscmx")
Dim filter As String = "1=1"
With e.Form.Controls("DateTimePicker1")
If .Value IsNot Nothing Then
   If stade.text >"" Then
     Filter = Filter & " And "
   End If
\'      filter= filter & " and a.InDate >=\'" & stade.text & "\'"
       filter= filter & "a.InDate >=\'" & stade.text & "\'"
End If
End With

With e.Form.Controls("DateTimePicker2")
If .Value IsNot Nothing Then
    If  Endde.text>"" Then
      Filter = Filter & " And "
    End If
\'     filter=filter & " and a.InDate <= \'" & Endde.text & "\'"
       filter=filter & "a.InDate <= \'" & Endde.text & "\'"
End If
End  With

With e.Form.Controls("ComboBox1")
If .Value IsNot Nothing Then
    If cs01.text>"" Then
      Filter = Filter & " And "
    End If
       filter=filter & "[物供号] = \'" & cs01.text & "\'"
End If
End  With

With e.Form.Controls("ComboBox2")
If .Value IsNot Nothing Then
    If cs02.text>"" Then
      Filter = Filter & " And "
    End If
       filter=filter & "[类别] = \'" & cs02.text & "\'"
End If
End  With

With e.Form.Controls("ComboBox3")
If .Value IsNot Nothing Then
    If cs03.text>"" Then
      Filter = Filter & " And "
    End If
       filter=filter & "[厂号] = \'" & cs03.text & "\'"
End If
End  With

With e.Form.Controls("ComboBox4")
If .Value IsNot Nothing Then
    If cs04.text>"" Then
      Filter = Filter & " And "
    End If
       filter=filter & "[客款号] = \'" & cs04.text & "\'"
End If
End  With


If Filter > "" Then
    dt.LoadFilter=filter
    dt.Load()
End If


--  作者:有点甜
--  发布时间:2018/5/21 14:24:00
--  

1、代码没问题; http://www.foxtable.com/webhelp/scr/1058.htm

 

2、如果报错,说明你dt没有写的那些列,你列名绝对写错了;

 

3、不会做请上传具体实例测试。


--  作者:yetle
--  发布时间:2018/5/21 14:32:00
--  
DataTables("dbscmx")是sql查询表:怎么会写错呢?

替换成sql查询表的列名就可以了
[此贴子已经被作者于2018/5/21 14:36:41编辑过]

--  作者:有点甜
--  发布时间:2018/5/21 15:08:00
--  
那就是列名写错了,改成正确的对应的列名即可。