以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  求助多条件查找find用法  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=73170)

--  作者:好好学习天天向上
--  发布时间:2015/8/13 16:18:00
--  求助多条件查找find用法
有AB两个表,表A有日期、产品、价格 3列,表B有产品、日期起、日期止、执行价格 4列,表A中产品的价格根据表B中不同时间段执行不同的价格,代码红色部分加上了日期条件就错了,该怎么写?

If e.DataCol.Name = "产品" Then
    Dim dr As DataRow
  dr = DataTables("表B").Find("产品 = " & "\'" & e.DataRow("产品") & "\'" And "日期起 <= " & "\'" & e.DataRow("日期") & "\'"  And "日期止 >= " & "\'" & e.DataRow("日期") & "\'"  )                   
    If dr IsNot Nothing
        e.DataRow("价格")= dr("执行价格")
    End If
End If


--  作者:大红袍
--  发布时间:2015/8/13 16:29:00
--  
If e.DataCol.Name = "产品" Then
    Dim dr As DataRow
  dr = DataTables("表B").Find("产品 = \'" & e.DataRow("产品") & "\' And 日期起 <= #" & e.DataRow("日期") & "# And 日期止 >= #" & e.DataRow("日期") & "#"  )                  
    If dr IsNot Nothing
        e.DataRow("价格")= dr("执行价格")
    End If
End If

--  作者:有点蓝
--  发布时间:2015/8/13 16:31:00
--  
and 前后 也加个 & 连接符号
[此贴子已经被作者于2015/8/13 16:31:12编辑过]

--  作者:好好学习天天向上
--  发布时间:2015/8/13 16:33:00
--  
谢谢指导!