MS Access查询检查表单字段是否为空 [英] MS Access query check if form field is empty

查看:249
本文介绍了MS Access查询检查表单字段是否为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多字段表单,并使用它来检索表的记录.如果在字段中没有用户输入,我想在相应的列中允许"*"和Null值,则用户输入否则.

I have a multi-field form and use it to retrieve records of a table. If there is no user input in a field I want to allow "*" and Null Values for the according column, the user input otherwise.

我尝试过

Like IIf([Forms]![frm_searchForm]![Titel]="" Or IsNull([Forms]![frm_searchForm]![Titel]);Like "*" Or Is Null;[Forms]![frm_searchForm]![Titel])

以及

Like IIf(IsEmpty([Forms]![frm_searchForm]![Titel]);Like "*" Or Is Null;[Forms]![frm_searchForm]![Titel])

但是在两种情况下,IIf函数始终会触发else表达式. 如何检查表单中的字段是否为空?如果没有VB,这是否有可能?

But in both cases, the IIf function always triggers the else expression. How can I check whether the field in the form is empty? Is this even possible without VB?

谢谢

推荐答案

AFAICT,当[Forms]![frm_searchForm]![Titel]包含值时,您只希望某些字段包含该值的行.

AFAICT, when [Forms]![frm_searchForm]![Titel] contains a value, you want only those rows where some field contains that value.

但是,如果[Forms]![frm_searchForm]![Titel]为Null或为空字符串,则要检索所有行.

But, if [Forms]![frm_searchForm]![Titel] is Null or an empty string, you want to retrieve all the rows.

如果正确,请尝试类似于以下内容的WHERE子句:

If that is correct, try a WHERE clause similar to this:

WHERE
       Len([Forms]![frm_searchForm]![Titel] & '') = 0
    OR some_field Like '*' & [Forms]![frm_searchForm]![Titel] & '*'

还要在您的SQL语句的开头添加一个PARAMETERS子句:

Also add a PARAMETERS clause at the beginning of your SQL statement:

PARAMETERS [Forms]![frm_searchForm]![Titel] Text ( 255 );

这篇关于MS Access查询检查表单字段是否为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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