没有为docmd.applyfilter处理结果 [英] Handling no results for docmd.applyfilter

查看:312
本文介绍了没有为docmd.applyfilter处理结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Access应用程序,可以在其中使用搜索功能.我在窗体上有一个TextBox和一个Search Button,它对用户在TextBox中输入的内容进行通配符搜索,并在其他控件(文本和组合框)中显示记录.

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the records in other controls (Text and Combo Boxes).

要实现此目的,我正在使用DoCmd.ApplyFilter方法,我想知道是否有一种方法可以处理无结果"情况?它当前所做的是将所有显示控件显示为空,并且ID字段显示(AutoNumber)就像我要添加新记录一样.

To achieve this, I am using the DoCmd.ApplyFilter method and I wanted to know if there is a way that I can handle the 'no results' scenario? What it does currently is shows all the display controls as empty, and the ID field says (AutoNumber) as if I was adding a new record.

如果使用DoCmd.ApplyFilter无法处理任何结果,那么还有另一种方法来搜索记录并处理无结果"情况吗?

If it is not possible to handle no results with DoCmd.ApplyFilter, then is there another way to search the records and handle the 'no results' scenario as well?

推荐答案

您可以检查recordsetclone来查看是否有任何记录,如果没有,则删除过滤器.

You can check the recordsetclone to see if there are any records and remove the filter if there are not.

DoCmd.ApplyFilter , "id=5"
If Me.RecordsetClone.RecordCount = 0 Then
    MsgBox "No records"
End If

这篇关于没有为docmd.applyfilter处理结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆