以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  内部函数无法执行的问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=186548)

--  作者:HANZHIGANG
--  发布时间:2023/5/11 12:12:00
--  内部函数无法执行的问题
全局代码中代码
Public Filter As String

内部函数中代码
If Filter > "" Then
    Tables(Maintable.Name).DataTable.loadfilter = Filter
    Tables(Maintable.Name).DataTable.load
Else
    Tables(Maintable.Name).DataTable.loadfilter = ""
    Tables(Maintable.Name).DataTable.load
End If
Forms ("导航窗口").Controls("TextBox1").Value = 1 & "/" & Tables(Maintable.Name).DataTable.TotalPages

窗口中全局事件Click代码
With e.Form.Controls("上游客户")
    If .text > "" Then
        Filter = "上游客户 like \'%" & .text & "%\'"
    End If
End With

With e.Form.Controls("品牌")
    If .text > "" Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "品牌 like \'%" & .text & "%\'"
    End If
End With

With e.Form.Controls("商品车")
    If .text > "" Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "商品车 like \'%" & .text & "%\'"
    End If
End With

With e.Form.Controls("备注")
    If .text > "" Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "备注 like \'%" & .text & "%\'"
    End If
End With


Select Case e.Sender.Name
    Case "查询" 
        Functions.Execute("查询")
        
    Case "清除"
        Functions.Execute("清除", e) \'清除窗口查询条件
End Select

第一次执行查询按钮,是没有问题的,可以按条件加载数据。
但是如果击清除按钮后,再点击查询,就没有反应了
老师帮分析一下原因,及解决的办法



--  作者:HANZHIGANG
--  发布时间:2023/5/11 12:14:00
--  
清除的内部函数代码如下
Dim e = args(0)
For Each c As WinForm.Control In e.Form.Controls
    If TypeOf c Is WinForm.TextBox Then \'判断控件是否是文本框
        Dim t As WinForm.TextBox = c \'使用特定类型的变量引用控件
        t.Text = ""
    End If
Next

For Each c1 As WinForm.Control In e.Form.Controls
    If TypeOf c1 Is WinForm.ComboBox Then \'判断控件是否是文本框
        Dim t1 As WinForm.ComboBox = c1 \'使用特定类型的变量引用控件
        t1.Text = ""
    End If
Next

For Each c2 As WinForm.Control In e.Form.Controls
    If TypeOf c2 Is WinForm.DateTimePicker Then \'判断控件是否是文本框
        Dim t2 As WinForm.DateTimePicker = c2 \'使用特定类型的变量引用控件
        t2.text = ""
    End If
Next

--  作者:有点蓝
--  发布时间:2023/5/11 13:35:00
--  
调试

内部函数中代码
msgbox(Filter)
If Filter > "" Then
    Tables(Maintable.Name).DataTable.loadfilter = Filter
……

窗口中全局事件Click代码
……
Select Case e.Sender.Name
    Case "查询" 
msgbox(1)
        Functions.Execute("查询")
        
    Case "清除"
msgbox(2)
        Functions.Execute("清除", e) \'清除窗口查询条件
End Select