如何测试在搜索记录时是否找不到匹配项? [英] How to test if a match isn't found in searching for a record?

查看:78
本文介绍了如何测试在搜索记录时是否找不到匹配项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表单上有一个文本框,允许我输入一个贷款号码,然后它会转到那笔贷款。我的问题是,如果我输入的数字不存在,则没有任何反应。我最初的想法是会发生错误,我可能会陷入错误,以便在找不到匹配项时执行我想要发生的步骤。但是我没有错误陷阱。我已经尝试了DoCmd.SearchForRecord和Me.Recordset.FindFirst。前者什么也没做,后者只是去了第一张唱片。我可以用什么来查看是否找不到匹配项?

I have a textbox on my form that allows me to type in a loan number and it will go to that loan. My problem is that if the number that I type in doesn''t exist, nothing happens. My initial thought was that an error would occur and I could trap for the error to perform the steps that I want to happen when a match isn''t found. But no error occurs for me to trap. I have tried both DoCmd.SearchForRecord and Me.Recordset.FindFirst. The former does nothing and the later just goes to the first record. What can I use to see if no match was found?

推荐答案

您可以在进行搜索之前使用DCount。
You could use a DCount before doing the search.


你的意思是使用贷款编号的标准DCount表格的数据来源吗?
Do you mean DCount the data source of the form using a criteria of the loan number?


嗯,它确实有效,即使那不是你的意思,尽管我认为它是。谢谢兔子。
Well, it does work that way even if that wasn''t what you were meaning, although I think that it was. Thanks Rabbit.


这篇关于如何测试在搜索记录时是否找不到匹配项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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