在 MS Access 中如何处理布尔类型列中的 NULL 值?
我想知道除了将列数据类型更改为整数之外,是否有更好的方法来解决 MS-Access 无法处理布尔值的 NULL 问题。
I was wondering if there is a better way to cope with MS-Access' inability to handle NULL for boolean-values other than change the column-data-type to integer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
并不是我发现的:( 我已经有一段时间没有编写 Access 了,但我记得涉及相当多的 isNull 检查。
Not that I've found :( I haven't programmed Access in awhile, but what I remember involves quite a lot of isNull checks.
我认为这取决于您希望您的应用程序/解决方案如何解释数据中的空值。
您是否想在报告中简单地“忽略”它们...即有它们打印为空格或换行符? 在这种情况下,您可以在 SQL 生成器或常规 Access 查询设计器中的列中使用方便的 IsNull 函数以及“立即 if”iif(),如下所示:
IIF(IsNull(BooleanColumnName), NewLine/BlankSpace/Whatever, BooleanColumnName)
另一方面,如果您想要要将 NULL 视为“False”值,您最好更新列并使用以下内容更改它们:
Update table
SET BooleanColumnName > = FALSE
WHERE BooleanColumnName IS NULL
I think it depends on how you want your app/solution to interpret said NULLs in your data.
Do you want to simply "ignore" them in a report... i.e. have them print out as blank spaces or newlines? In that case you can use the handy IsNull function along with the "immediate if" iif() in either the SQL builder or a column in the regular Access query designer as follows:
IIF(IsNull(BooleanColumnName), NewLine/BlankSpace/Whatever, BooleanColumnName)
On the other hand, if you want to consider the NULLs as "False" values, you had better update the column and just change them with something like:
Update table
SET BooleanColumnName = FALSE
WHERE BooleanColumnName IS NULL
我认为您必须使用数字,因此,Allen Browne,Access MVP 似乎确实如此。
I think you must use a number, and so, it seems does Allen Browne, Access MVP.