如何在MS Access中处理类型为boolean的列中的NULL值?

时间:2022-02-22 15:38:11

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.

我想知道是否有更好的方法来处理MS-Access无法处理布尔值的NULL,而不是将column-data-type更改为整数。

3 个解决方案

#1


2  

I think you must use a number, and so, it seems does Allen Browne, Access MVP.

我认为你必须使用一个数字,所以,似乎Allen Browne,Access MVP。

#2


0  

Not that I've found :( I haven't programmed Access in awhile, but what I remember involves quite a lot of isNull checks.

不是我发现:(我有一段时间没有编程Access,但我记得涉及很多isNull检查。

#3


0  

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

我认为这取决于您希望您的应用/解决方案如何解释数据中的所述NULL。您是否想在报告中简单地“忽略”它们...即将它们打印为空格或换行符?在这种情况下,您可以在SQL构建器或常规Access查询设计器中的列中使用方便的IsNull函数以及“immediate if”iif(),如下所示:IIF(IsNull(BooleanColumnName),NewLine / BlankSpace / Whatever, BooleanColumnName)另一方面,如果要将NULL视为“False”值,最好更新列,只需更改它们:Update table SET BooleanColumnName = FALSE WHERE BooleanColumnName IS NULL

#1


2  

I think you must use a number, and so, it seems does Allen Browne, Access MVP.

我认为你必须使用一个数字,所以,似乎Allen Browne,Access MVP。

#2


0  

Not that I've found :( I haven't programmed Access in awhile, but what I remember involves quite a lot of isNull checks.

不是我发现:(我有一段时间没有编程Access,但我记得涉及很多isNull检查。

#3


0  

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

我认为这取决于您希望您的应用/解决方案如何解释数据中的所述NULL。您是否想在报告中简单地“忽略”它们...即将它们打印为空格或换行符?在这种情况下,您可以在SQL构建器或常规Access查询设计器中的列中使用方便的IsNull函数以及“immediate if”iif(),如下所示:IIF(IsNull(BooleanColumnName),NewLine / BlankSpace / Whatever, BooleanColumnName)另一方面,如果要将NULL视为“False”值,最好更新列,只需更改它们:Update table SET BooleanColumnName = FALSE WHERE BooleanColumnName IS NULL