Foxtable(狐表)用户栏目专家坐堂 → 交叉统计查询的问题求助?


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

主题:交叉统计查询的问题求助?

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/6/22 9:23:00 [显示全部帖子]

Dim Filter As String
With e.Form.Controls("cmbProduct")
    If .Value IsNot Nothing Then
        Filter = "地址 = '" & .Value & "'"
    End If
End With

 

改成,留意红色代码

 

Dim Filter As String
With e.Form.Controls("cmbProduct")
    If .Value IsNot Nothing Then
        Filter = "地址 in ('" & .Value.Replace(",", "','") & "')"
    End If
End With


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/6/22 11:13:00 [显示全部帖子]

 时间,不是只有一个值么?不用改。

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/6/22 14:05:00 [显示全部帖子]

 你说的不能交叉是什么意思啊,我测试是可以正常查询的啊。

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/6/22 14:23:00 [显示全部帖子]

 代码

 

Dim Filter As String
With e.Form.Controls("cmbProduct")
    If .Value IsNot Nothing Then
        Filter =  "地址 in ('" & .Value.Replace(",", "','") & "')"
    End If
End With
With e.Form.Controls("cmbCustomer")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter &= "吃饭 in ('" & .Value.Replace(",", "','") & "')"
    End If
End With
With e.Form.Controls("cmbEmployee")
    If .Value IsNot Nothing Then
        If Filter >"" Then
            Filter = Filter & " And "
        End If
        Filter &= "车费 in ('" & .Value.Replace(",", "','") & "')"
    End If
End With
With e.Form.Controls("StartDate")
    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 e.Form.Controls("rdoYifu").Checked = True ' 如果付款状态选择了"已付"
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "已记录 = True"
End If
If e.Form.Controls("rdoWeifu").Checked = True ' 如果付款状态选择了"未付"
    If Filter >"" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "(已记录 = False Or 已记录 Is Null)"
End If
If Filter > "" Then
    Tables("交叉").Filter = Filter
End If


 回到顶部