以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  筛选问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=59866)

--  作者:tina2012
--  发布时间:2014/11/12 15:29:00
--  筛选问题
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=59807&skin=0

昨天提的问题,会出现如下问题


图片点击可在新窗口打开查看此主题相关图片如下:0.jpg
图片点击可在新窗口打开查看

这句代码有错误:
Tables("Sales_Order_Product").Filter = "OrderId In (" & DataTables("Sales_Order_List").GetComboListString("Id", Tables("Sales_Order_List").Filter).Replace("|", ",") & ")"


Dim conStart As WinForm.DateTimePicker = e.Form.Controls("DateTimeStart")
Dim conEnd As WinForm.DateTimePicker = e.Form.Controls("DateTimeEnd")

Dim b As New SQLGroupTableBuilder("统计表1","Sales_Order_List")
b.C

Tables("Sales_Order_List").Filter = "SubmitDate >= #" & conStart.text & "# And SubmitDate <= #" & conEnd.text & "# And SubmitUserName = \'" & _UserName & "\'"  
Tables("Sales_Order_Product").Filter = "OrderId In (" & DataTables("Sales_Order_List").GetComboListString("Id", Tables("Sales_Order_List").Filter).Replace("|", ",") & ")"
b.Filter = Tables("Sales_Order_Product").Filter

b.AddTable("Sales_Order_Product","OrderId","Sales_Order_List","Id")
b.AddTable("Sales_Order_Product","ProductId","Sales_Product_List","Id")
b.AddTable("Sales_Order_List","CustomerId","Customer_List","Id")
b.Groups.AddDef("{Sales_Product_List}.Name")
b.Groups.AddDef("{Customer_List}.Name")
b.Groups.AddDef("{Sales_Order_List}.SubmitDate")
b.Groups.AddDef("{Sales_Order_List}.SubmitUser")
b.Totals.AddDef("Amount")
\'b.Totals.AddExp("SalesPrice2","已交数量*Price")
b.Build   \'生成统计表

Tables("统计分析_Table1").DataSource = b.BuildDataSource()


--  作者:有点甜
--  发布时间:2014/11/12 15:31:00
--  

Tables("Sales_Order_Product").Filter = "OrderId In (" & DataTables("Sales_Order_List").GetComboListString("Id", Tables("Sales_Order_List").Filter).Replace("|", ",") & ")"

 

改成

 

Tables("Sales_Order_Product").Filter = "OrderId In (\'" & DataTables("Sales_Order_List").GetComboListString("Id", Tables("Sales_Order_List").Filter).Replace("|", "\',\'") & "\')"


--  作者:tina2012
--  发布时间:2014/11/12 15:36:00
--  
之前试过了,不行,有错误


--  作者:有点甜
--  发布时间:2014/11/12 15:38:00
--  
什么错误?
--  作者:tina2012
--  发布时间:2014/11/12 15:38:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:3.jpg
图片点击可在新窗口打开查看

--  作者:有点甜
--  发布时间:2014/11/12 15:40:00
--  

Tables("Sales_Order_Product").Filter = "OrderId In (" & DataTables("Sales_Order_List").GetComboListString("Id", Tables("Sales_Order_List").Filter).Replace("|", ",") & ")"

 

改成

 

Dim str As String = DataTables("Sales_Order_List").GetComboListString("Id", Tables("Sales_Order_List").Filter).Replace("|", ",")

If str > "" Then
    Tables("Sales_Order_Product").Filter = "OrderId In (" & DataTables("Sales_Order_List").GetComboListString("Id", Tables("Sales_Order_List").Filter).Replace("|", ",") & ")"
Else
    Tables("Sales_Order_Product").Filter = "1=2"   
End If