以文本方式查看主题
- Foxtable(狐表) (http://foxtable.net/bbs/index.asp)
-- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2)
---- 窗口代码问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=8337)
|
-- 作者:wqc360
-- 发布时间:2010/10/8 17:37:00
-- 窗口代码问题
请问我在点击主表目录树节点时,出现如下错误提示:
此主题相关图片如下:未命名.gif
窗口控件姓名和年月都是绑定到主表列,控件ValueChanged代码如下:
Dim Filter As String With e.Form.Controls("姓名") If .Value IsNot Nothing Then Filter = "姓名 = \'" & .Value & "\'" End If End With With e.Form.Controls("年月") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "年月 = \'" & .Value & "\'" End If End With Dim dd As WinForm.TextBox = e.Form.Controls("年月") Dim dd1 As WinForm.TextBox = e.Form.Controls("姓名") Dim Filter1 As String With e.Form.Controls("姓名") If .Value IsNot Nothing Then Filter1 = "姓名 = \'" & .Value & "\'" End If End With With e.Form.Controls("年月") If .Value IsNot Nothing Then If dd1 IsNot Nothing Then Dim d1 As Date = DataTables("主管考勤").Compute("min(日期)", "[姓名] = \'" & dd1.text & "\' And [年月] = \'" & dd.text & "\' ") Dim dr As DataRow = DataTables("主管考勤").Find("[姓名] = \'" & dd1.text & "\' and [日期] = #" & d1.AddDays(-10) & "# ") If dr IsNot Nothing Then If Filter1 > "" Then Filter1 = Filter1 & " And " End If Filter1 = Filter1 & "年月 = \'" & dr("年月") & "\'" End If End If End If End With If Filter > "" Then Tables("主管考勤月统计查询_Table1").Filter = Filter End If If Filter1 > "" Then Tables("主管考勤月统计查询_Table2").Filter = Filter1 End If Tables("主管考勤月统计查询_Table1").Sort = "日期" \'排序 Tables("主管考勤月统计查询_Table2").Sort = "日期" \'排序
|
-- 作者:wqc360
-- 发布时间:2010/10/8 18:00:00
--
奇怪,我把代码改成如下,没有提示:
Dim Filter As String With e.Form.Controls("姓名") If .Value IsNot Nothing Then Filter = "姓名 = \'" & .Value & "\'" End If End With With e.Form.Controls("年月") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "年月 = \'" & .Value & "\'" End If End With If Filter > "" Then Tables("主管考勤月统计查询_Table1").Filter = Filter End If Tables("主管考勤月统计查询_Table1").Sort = "日期" \'排序 Dim dd As WinForm.TextBox = e.Form.Controls("年月") Dim dd1 As WinForm.TextBox = e.Form.Controls("姓名") Dim Filter1 As String With e.Form.Controls("姓名") If .Value IsNot Nothing Then Filter1 = "姓名 = \'" & .Value & "\'" Else Return End If End With With e.Form.Controls("年月") If .Value IsNot Nothing Then If Filter1 > "" Then Dim d1 As Date = DataTables("主管考勤").Compute("min(日期)", "[姓名] = \'" & dd1.text & "\' And [年月] = \'" & dd.text & "\' ") Dim dr As DataRow = DataTables("主管考勤").Find("[姓名] = \'" & dd1.text & "\' and [日期] = #" & d1.AddDays(-10) & "# ") If dr IsNot Nothing Then Filter1 = Filter1 & " And " Else Return End If Filter1 = Filter1 & "年月 = \'" & dr("年月") & "\'" Else Return End If Else Return End If End With
\'If Filter1 > "" Then \' Filter1 = Filter1 & " And " \'End If \'Filter1 = Filter1 & " 日期 >= #" & d1.AddDays(-6) & "# and 日期 <= #" & d1.AddDays(-1) & "# "
If Filter1 > "" Then Tables("主管考勤月统计查询_Table2").Filter = Filter1 End If Tables("主管考勤月统计查询_Table2").Sort = "日期" \'排序
|
-- 作者:czy
-- 发布时间:2010/10/8 20:18:00
--
看看1楼d1变量值是什么?
|
-- 作者:wqc360
-- 发布时间:2010/10/8 22:31:00
--
没看出问题,还请C版指点,谢谢
|
-- 作者:czy
-- 发布时间:2010/10/8 22:57:00
--
感觉你的代码很乱,一会引用控件值,一会又引用控件文本,而有时又引用主表字段值。
既然是ValueChanged事件,个人感觉就不应该引用"控件.Text,而应该用"控件.Value"。
其它真没看出什么,不过你可以测试一下动态组合后的变量值,比如MessageBox.Show(Filter1)、MessageBox.Show(Filter),看看它们组合后的表达式是否正确。
|