以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  查询异常  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=160563)

--  作者:nuoyan89
--  发布时间:2021/2/6 9:43:00
--  查询异常

老师,请帮忙看看以下代码,不能按要求查询如图1,请帮忙看看,谢谢 

Dim Filter As String
With e.Form.Controls("申请单号3")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = "申请单号 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("材料编码3")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter = "材料编码 = \'" & .Value & "\'"
    End If
End With
If Filter >"" Then
    e.Form.controls("记录明细").Table.DataTable.LoadPage = 0
    e.Form.controls("记录明细").Table.DataTable.LoadFilter = filter
    e.Form.controls("记录明细").Table.DataTable.Load
End If
With Tables("来料检测明细_记录明细")
    .Select(.RowSel, .Cols("创建日期").Index)
End  With
Dim filter2 As String
With e.Form.Controls("申请单号3")
    If .Value IsNot Nothing Then
        If filter2 >"" Then
            filter2 = filter2 & " And "
        End If
        filter2 = "审核单据编码 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("材料编码3")
    If .Value IsNot Nothing Then
        If filter2 >"" Then
            filter2 = filter2 & " And "
        End If
        filter2 = "单据内容 = \'" & .Value & "\'"
    End If
End With
If filter2 >"" Then
    e.Form.controls("过程审核").Table.DataTable.LoadPage = 0
    e.Form.controls("过程审核").Table.DataTable.Loadfilter = filter2
    e.Form.controls("过程审核").Table.DataTable.Load
End If
With Tables("来料检测明细_过程审核")
    .Select(.RowSel, .Cols("创建日期").Index)
End  With


图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:kk 2021-02-06 09-29-39.zip

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:kk 2021-02-06 09-29-39.zip

[此贴子已经被作者于2021/2/19 9:57:59编辑过]

--  作者:xongyijd
--  发布时间:2021/2/6 13:34:00
--  
 把第一个条件去掉:  If Filter >"" Then
            Filter = Filter & " And "
        End If
--  作者:有点蓝
--  发布时间:2021/2/7 9:35:00
--  
没看懂,哪个数据有问题?
--  作者:nuoyan89
--  发布时间:2021/2/19 10:00:00
--  
如1楼红色代码,查询出来的结果显示的却是如图1,真正要显示的是如图1用红框圈起来的些,但其他的也跟着显示出来了
--  作者:有点蓝
--  发布时间:2021/2/19 10:05:00
--  
代码没有问题。看看是不是控件名称写错了,或者有其它代码影响

End With
msgbox(filter2 )
If filter2 >"" Then
    e.Form.controls("过程审核").Table.DataTable.LoadPage = 0
    e.Form.controls("过程审核").Table.DataTable.Loadfilter = filter2
    e.Form.controls("过程审核").Table.DataTable.Load
End If

--  作者:nuoyan89
--  发布时间:2021/2/19 10:39:00
--  

重新看了下,没有冲突,是代码有问题。

Dim filter2 As String
With e.Form.Controls("申请单号3")
    If .Value IsNot Nothing Then
        If Filter2 >"" Then
            Filter2 = Filter2 & " And "
        End If
        Filter2 = Filter2 & "审核单据编码 = \'" & .Value & "\'"
    End If
End With
With e.Form.Controls("材料编码3")
    If .Value IsNot Nothing Then
        If filter2 >"" Then
            filter2 = filter2 & " And "
        End If
        Filter2 = Filter2 & "单据内容 = \'" & .Value & "\'"
    End If
End With