Microsoft Access Query 应返回真或真假,只返回真 [英] Microsoft Access Query Should return true or true and false, only returns true

查看:19
本文介绍了Microsoft Access Query 应返回真或真假,只返回真的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行访问查询.有一个带有是/否框的字段.查询条件参数是IIf([Type True or All]=True",-1,>-2).但即使它评估为 false,它也只返回 yes,它在访问中是 -1,而不是是和否,在 Access 中是 -1 和 0.如果我将条件设置为 >-2,那么它同时返回是和否.

I am making an access query . There is a field with a Yes/No box. The query criteria parameter is IIf([Type True or All]="True",-1,>-2). But even if it evaluates to false, it only returns yes, which in access is -1, not both yes and no, which in Access is -1 and 0. If I set the criteria as >-2, then it returns both Yes and No.

推荐答案

运算符(=、>、LIKE 等)不能是动态的.运算符必须是静态的,然后 IIf() 返回参数.

Operators (=, >, LIKE, etc) cannot be dynamic. The operator must be static, then IIf() returns parameter.

可以这样做:

WHERE fieldname LIKE IIf([Type True or All] = "True", -1, "*")

或者减少用户输入:

WHERE fieldname LIKE IIf([Type "T" for True or "A" for All] = "T", -1, "*").

或者这个:

WHERE fieldname LIKE Choose([Type 1 for True, 2 for False, 3 for All], -1, 0, *")

或用于文本字段:
WHERE fieldname LIKE IIf([enter value or ALL]=ALL",*", [enter value or ALL])

我不使用动态参数化查询 - 我更喜欢 VBA 来构建标准并应用于表单或报告.特别建议不要使用弹出式输入,因为它们无法验证,表单上的输入可以.

I don't use dynamic parameterized queries - I prefer VBA to build criteria and apply to form or report. Especially advise not to use popup inputs because they cannot be validated, inputs on form can.

这篇关于Microsoft Access Query 应返回真或真假,只返回真的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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