如何从查询中输出布尔值 [英] How to output a boolean from a query

查看:257
本文介绍了如何从查询中输出布尔值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MS Access 2007(使用Access 2000格式)中,我试图从查询中获取布尔输出,以使结果显示为复选框而不是0或-1.

In MS Access 2007 (using Access 2000 format) I am attempting to get a boolean output from a query such that the result is displayed as a checkbox rather than 0 or -1.

当查询沿布尔输入传递时,这将正常工作.当我尝试进行评估时,结果为0或-1,但不是TRUE/FALSE复选框.

When the query is passing along a boolean input, this is working properly. When I attempt to make an evaluation, the result is 0 or -1, but not a TRUE/FALSE checkbox.

我尝试过:

SELECT (MyInt > 1) AS MyBoolResult
SELECT CBool(MyInt > 1) AS MyBoolResult
SELECT IIF((MyInt > 1), TRUE, FALSE) AS MyBoolResult
SELECT CBool(IIF((MyInt > 1), TRUE, FALSE)) AS AS MyBoolResult

在每种情况下,我的结果都是0或-1,并且无法使用GridView将其放入ASP .Net网页中的显示复选框.

In each case my result is a 0 or -1, and I cannot get this into a display checkbox down stream in an ASP .Net web page using a GridView.

我想要的是可能的吗?如果是这样,它是如何完成的?

Is what I want possible? If so, how is it accomplished?

推荐答案

在设计视图中查询时,在字段表达式框中单击,然后按Alt + F11弹出属性表.如果然后切换到查找"选项卡,则可以看到显示控件"只有三个三个选择:文本框",文本框"和文本框".列表框;和组合框.您可以输入Check Box,但不会被接受.

With your query in design view, click in your field expression box, then press Alt+F11 to bring up the property sheet. If you then switch to the Lookup tab, you can see there are only 3 three choices for Display Control: Text Box; List Box; and Combo Box. You can type in Check Box, but it won't be accepted.

因此,在Access 2007查询的结果集中,您无法将计算出的字段表达式显示为复选框.

So, you can't have a calculated field expression displayed as a check box in the result set from an Access 2007 query.

更新:我可能误告知了您.如果确实有显示控件"的复选框"选项,请选择它. (我的系统上没有可用的选择,但是我正在第二次猜测我的系统是否正常.)

Update: I may have misinformed you. If you do have a Check Box option for Display Control, choose it. (I don't have that choice available on my system, but I'm second guessing whether my system is normal.)

如果您要显示的不是-1或0,则可以尝试在字段属性页的格式"框中输入True/False(是/否).

If you want something displayed other than -1 or 0, you could try entering True/False (or Yes/No) in the Format box on the field's property sheet.

这篇关于如何从查询中输出布尔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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