Access交流中心

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

[5分]刷新问题?

jia  发表于:2011-04-25 09:44:28  
复制

各位老师好:

在进行查询后,按下“返回”键后可否根据“选取光交接箱”的条件显示其内容,而不是显示全部数据哪?

点击下载此附件

 

Top
煮江品茶 发表于:2011-04-25 14:38:01

你的代码杂乱无章,可以全部删除之,以下面的代码替代。

 

Function Allfilter()
Dim strWhere As String
Dim ctls As Controls
Dim ctl As Control
Dim str As String
strWhere = "True"
If IsNull(Me.Text3.Value) = False Then
    strWhere = strWhere & " AND [设备名称]= '" & Me.Text3.Value & "'"
    If IsNull(Me.Text5.Value) = False Then

        Set ctls = Me.曙采招待所光交箱资料.Form.Controls
        For Each ctl In ctls
            If ctl.ControlType <> acLabel Then
                If ctl.Name <> "设备名称" Then
                    str = str & "[" & ctl.Name & "] & "
                End If
            End If
        Next ctl
        str = Left(str, Len(str) - 3)
        strWhere = strWhere & " AND (" & str & " Like '*" & Me.Text5.Value & "*')"
        MsgBox strWhere
    End If
End If
Me.曙采招待所光交箱资料.Form.Filter = strWhere
Me.曙采招待所光交箱资料.Form.FilterOn = True
End Function

 

Private Sub Text3_AfterUpdate()
Call Allfilter
End Sub

 

Private Sub 查询_Click()
Select Case Me.查询.Caption
        Case "返回"
            Me.Text5.Value = Null
            Me.查询.Caption = "查询"
        Case "查询"
            Me.查询.Caption = "返回"
End Select
Call Allfilter
End Sub

 



煮江品茶 发表于:2011-04-25 14:39:04
jia 发表于:2011-04-25 15:07:19
谢谢老师

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