会员登录 - 用户注册 - 网站地图 Office中国(office-cn.net),专业Office论坛
当前位置:主页 > 技巧 > Access技巧 > 窗体控件 > 正文

根据查找窗体设定的条件筛选主窗体的数据内容代码

时间:2013-08-04 21:06 来源:本站原创 作者:佚名 阅读:

If Me.开始日期 > Me.截止日期 Then
        MsgBox "您选择的开始日期晚于截止日期!", vbExclamation, "错误"
    Else
        Dim strWhere As String
        strWhere = True

        If Not IsNull(Me.开始日期) Then
            If Not IsNull(Me.截止日期) Then
                strWhere = strWhere & " and [车辆注册日期] between #" & Me!开始日期 & "# and #" & Me.截止日期 & "#"
            Else
                strWhere = strWhere & " and [车辆注册日期] >= #" & Me.开始日期 & "#"
            End If
        Else
            If Not IsNull(Me.截止日期) Then
                strWhere = strWhere & " and [车辆注册日期] <= #" & Me.截止日期 & "#"
            End If
        End If


        If Not IsNull(Me.车号) Then
            strWhere = strWhere & " and [车号] Like '*" & Me.车号 & "*'"
          
        End If

        If Not IsNull(Me.车型) Then
            strWhere = strWhere & " and [车型] = '" & Me.车型 & "'"
        End If

        With Forms!主控面板!Child0.Form!车辆信息_child.Form
            .Filter = strWhere
            .FilterOn = True
        End With
        DoCmd.Close acForm, Me.Name, acSaveNo

(责任编辑:admin)

顶一下
(0)
0%
踩一下
(0)
0%
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价: