Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

关于组合查询问题

皇帝  发表于:2009-01-24 10:15:34  
复制

我做了一个数据库,为了方便查询,做了个复合查询,希望做到的效果是:键入任一条件,均可查询,键入多个条件,可组合查询,不过似乎不成功,请各位帮忙修改一下,谢谢。点击下载此附件

 

Top
点点 发表于:2009-01-26 18:10:20
你提供的文件扩展名怎么为accdb?没法打开。关于查询可以参考下面的链接中的回复:http://www.accessoft.com/bbs/showtopic.asp?id=3256 自己修改相应代码就可以实现筛选。

皇帝 发表于:2009-01-27 19:58:27
抱歉,因为是用2007版的office,现在重新保存为2003版的,希望各位帮忙,另外6100535的回复我也会去看看的,谢谢。点击下载此附件

ACMAIN.CHM 发表于:2009-01-27 21:08:30
Option Compare Database
Option Explicit

Private Sub find1_Click()

    Dim strWhere As String
    strWhere = ""
    
    If Me.jlrq.Value <> "" Then
        If strWhere <> "" Then
            strWhere = strWhere & " and "
        End If
        strWhere = strWhere & "建立日期 = #" & Me.jlrq.Value & "#"
    End If
    
    If Me.z.Value <> "" Then
        If strWhere <> "" Then
            strWhere = strWhere & " and "
        End If
        strWhere = strWhere & "建立日期 >= #" & Me.z.Value & "#"
    End If
    
    If Me.To.Value <> "" Then
        If strWhere <> "" Then
            strWhere = strWhere & " and "
        End If
        strWhere = strWhere & "建立日期 <= #" & Me.To.Value & "#"
    End If
        
    If Me.nl.Value <> "" Then
        If strWhere <> "" Then
            strWhere = strWhere & " and "
        End If
        strWhere = strWhere & "年龄 like '*" & Me.nl.Value & "*'"
    End If
    
    If Me.xb.Value <> "" Then
        If strWhere <> "" Then
            strWhere = strWhere & " and "
        End If
        strWhere = strWhere & "性别 = '" & Me.xb.Value & "'"
    End If
        
    If Me.hj.Value <> "" Then
        If strWhere <> "" Then
            strWhere = strWhere & " and "
        End If
        strWhere = strWhere & "户籍 like '*" & Me.hj.Value & "*'"
    End If
        
    If Me.fflx.Value <> "" Then
        If strWhere <> "" Then
            strWhere = strWhere & " and "
        End If
        strWhere = strWhere & "付费类型='" & Me.fflx.Value & "'"
    End If

    If Me.glz.Value <> "" Then
        If strWhere <> "" Then
            strWhere = strWhere & " and "
        End If
        strWhere = strWhere & "管理者='" & Me.glz.Value & "'"
    End If

    
    Me.findchild.Form.Filter = strWhere
    Me.findchild.Form.FilterOn = True
    
    
End Sub




皇帝 发表于:2009-01-28 14:38:05
谢谢上面的帮忙,不过在年龄与日期查询方面似乎总不行···

皇帝 发表于:2009-02-04 13:05:02
不晓得为什么年龄段与日期段查询不行···

总记录:5篇  页次:1/1 9 1 :