以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]同一数据表的2个窗口控件副本表同时按不同条件加载的问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=115945) |
-- 作者:1669607010 -- 发布时间:2018/3/17 8:39:00 -- [求助]同一数据表的2个窗口控件副本表同时按不同条件加载的问题 [求助]同一数据表的2个窗口控件副本表,一个副本表按 领料日期 加载,另一个副本表按 收纱日期 加载,现在想把代码写在一个按钮里,代码如下: Dim LoadFilter1 As
String With e.Form.Controls
("StartDate") If .Value IsNot Nothing Then If
LoadFilter1 >"" Then LoadFilter1 =
LoadFilter1 & " And
" End If LoadFilter1 =
LoadFilter1 & "领料日期
>= \'" & .Value & "\'" End If End With With e.Form.Controls
("EndDate") If .Value IsNot Nothing Then If
LoadFilter1 >"" Then LoadFilter1 =
LoadFilter1 & " And
" End If LoadFilter1 =
LoadFilter1 & "领料日期
<= \'" & .Value & "\'" End If End With
If LoadFilter1
> "" Then Tables("装卸车费管理_Table8").DataTable.LoadFilter
= LoadFilter1
End If Tables("装卸车费管理_Table8").Sort
= "领料日期"
Dim LoadFilter2 As
String With e.Form.Controls
("StartDate") If .Value IsNot Nothing Then If
LoadFilter2 >"" Then LoadFilter2 =
LoadFilter2 & " And
" End If LoadFilter2 =
LoadFilter2 & "收纱日期
>= \'" & .Value & "\'" End If End With With e.Form.Controls
("EndDate") If .Value IsNot Nothing Then If
LoadFilter2 >"" Then LoadFilter2 =
LoadFilter2 & " And
" End If LoadFilter2 =
LoadFilter2 & "收纱日期
<= \'" & .Value & "\'" End If End With
If LoadFilter2
> "" Then Tables("装卸车费管理_Table11").DataTable.LoadFilter
= LoadFilter2
End If
哪位老师帮忙看看,为什么第一个副本按 领料日期 加载的被第二个副本加载的给覆盖了,要怎样修改才能让两个副本分别按条件加载? |
-- 作者:有点蓝 -- 发布时间:2018/3/17 9:15:00 -- Dim LoadFilter1 As String With e.Form.Controls ("StartDate") If .Value IsNot Nothing Then If LoadFilter1 >"" Then LoadFilter1 = LoadFilter1 & " And " End If LoadFilter1 = LoadFilter1 & "领料日期 >= \'" & .Value & "\'" End If End With With e.Form.Controls ("EndDate") If .Value IsNot Nothing Then If LoadFilter1 >"" Then LoadFilter1 = LoadFilter1 & " And " End If LoadFilter1 = LoadFilter1 & "领料日期 <= \'" & .Value & "\'" End If End With Dim LoadFilter2 As String With e.Form.Controls ("StartDate") If .Value IsNot Nothing Then If LoadFilter2 >"" Then LoadFilter2 = LoadFilter2 & " And " End If LoadFilter2 = LoadFilter2 & "收纱日期 >= \'" & .Value & "\'" End If End With With e.Form.Controls ("EndDate") If .Value IsNot Nothing Then If LoadFilter2 >"" Then LoadFilter2 = LoadFilter2 & " And " End If LoadFilter2 = LoadFilter2 & "收纱日期 <= \'" & .Value & "\'" End If End With DataTable("副本表对应的主表名称").LoadFilter = LoadFilter1 & IIF(LoadFilter1 > "" AndAlso LoadFilter2 > ""," and " ,"") & LoadFilter2 DataTable("副本表对应的主表名称").load If LoadFilter1 > "" Then Tables("装卸车费管理_Table8").Filter = LoadFilter1 End If Tables("装卸车费管理_Table8").Sort = "领料日期" If LoadFilter2 > "" Then Tables("装卸车费管理_Table11").Filter = LoadFilter2 End If |
-- 作者:1669607010 -- 发布时间:2018/3/17 9:39:00 -- 蓝老师,执行完你的代码,怎么副本表都是空的,? |
-- 作者:有点蓝 -- 发布时间:2018/3/17 10:04:00 -- DataTable("副本表对应的主表名称").LoadFilter = LoadFilter1 & IIF(LoadFilter1 > "" AndAlso LoadFilter2 > ""," or " ,"") & LoadFilter2 |