Foxtable(狐表)用户栏目专家坐堂 → [求助]窗口多表查询


  共有7947人关注过本帖树形打印复制链接

主题:[求助]窗口多表查询

帅哥哟,离线,有人找我吗?
don
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1812 积分:12993 威望:0 精华:14 注册:2008/10/11 18:07:00
  发帖心情 Post By:2012/2/11 11:01:00 [显示全部帖子]

Dim Filter,sql As String
With e.Form.Controls("textbox1")
    If .Value IsNot Nothing Then
        Filter = "姓名 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("textbox2")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If 
        Filter = Filter & "车号 = '" & .Value & "'"
    End If
End With
With e.Form.Controls("StarDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If 
        Filter = Filter & "日期 >= #" & .Value & "#"
    End If
End With
With e.Form.Controls("EndDate")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If 
        Filter = Filter & "日期 <= #" & .Value & "#"
    End If
End With
If Filter > "" Then
    Tables("表B").Filter = Filter
Tables("表c").Filter = Filter
End If


sql = "Select 日期,姓名,车号,行程 From {表B} Where " & Filter 
sql+ = " UNION ALL Select 日期,姓名,车号,行程  From {表C} Where " & Filter


DataTables("表A").Fill(sql, "manager",True)


 回到顶部