用户如何在MS Access中插入null?

时间:2022-09-28 15:42:41

MS Access appears to support nulls in code, but I can't for the life of me figure out how to enter a null directly in a table. This is maddening because once a field has had a figure entered in it, it can never be deleted/set to null. Normally, allowing zero length strings would take care of this, but Access treats the XML export of a null and a zero length string differently. A null eliminates the associated XML tag and a zero length string sends an empty tag.

MS Access似乎支持代码中的空值,但我不能在我的生活中弄清楚如何直接在表中输入null。这很令人抓狂,因为一旦一个字段输入了一个数字,它就永远不会被删除/设置为空。通常,允许零长度字符串会处理此问题,但Access会以不同方式处理null和零长度字符串的XML导出。 null取消关联的XML标记,零长度字符串发送空标记。

7 个解决方案

#1


4  

Are you talking about needing to do it in Datasheet view? If you needed to do it in an update query, you can do it like this:

您是否正在谈论需要在数据表视图中执行此操作?如果您需要在更新查询中执行此操作,则可以这样执行:

UPDATE test SET test.test = Null;

#2


4  

Does setting the "Allow zero length string" option in the table definition help? It may force an empty string to be interpreted as NULL.

在表定义中设置“允许零长度字符串”选项是否有帮助?它可能会强制将空字符串解释为NULL。

#3


2  

press ctrl-0 and a null is inserted.

按ctrl-0并插入一个null。

#4


2  

Deleting all the characters will work, but Access is a bit fickle. Hitting backspace or delete will not work unless there are characters in the field. I find it is best to enter a few characters, select all, and hit delete, change focus and change the record. After all the above, if you run a query looking for "is null" the record will be found.

删除所有字符都可行,但Access有点变幻无常。除非字段中有字符,否则按下退格键或删除将不起作用。我发现最好输入几个字符,选择全部,然后点击删除,更改焦点并更改记录。完成上述所有操作后,如果您运行查询“is null”,则会找到该记录。

#5


0  

I'm actually looking for a way for a layperson to do the entry directly in a table. In MSSQL you can simply press ctrl-0 and a null is inserted. Deleting all the characters doesn't appear to work. Instead of a null, you are left with an empty string. They are not treated the same by Access for export purposes.

我实际上正在寻找一种方式让外行人直接在表格中进行输入。在MSSQL中,您只需按ctrl-0并插入null。删除所有字符似乎不起作用。而不是null,你留下一个空字符串。出于出口目的,Access不会对它们进行相同的处理。

I think what I'm going to wind up doing is creating an xslt file to use during export that eliminates empty tags. That way the user can't really tell the difference.

我想我最终要做的是创建一个在导出过程中使用的xslt文件,以消除空标记。这样,用户无法真正区分。

It sure would be nice, though, to be able to key in a null.

但是,能够键入空值肯定会很好。

#6


0  

Ok, I don't think this is an easily solvable problem and my original question was a little off target. The problem isn't so much with nulls, although they are involved, as with the manner in which the table was originally created. If you use an xsd file to create your tables you plan on exporting, something happens under the hood in Access that causes those fields to be treated a little differently than fields created with the editors.

好吧,我不认为这是一个容易解决的问题,我原来的问题有点偏离目标。问题不在于null,尽管它们涉及到,就像最初创建表的方式一样。如果您使用xsd文件来创建计划导出的表,那么在Access中会发生一些事情,导致这些字段的处理方式与使用编辑器创建的字段略有不同。

The only solution I found was to create a new field in the table, rename the old field, copy the data from the old field to the new field and delete the old field.

我找到的唯一解决方案是在表中创建一个新字段,重命名旧字段,将数据从旧字段复制到新字段并删除旧字段。

After doing that, then blank fields that had data in them at one point are no longer included in the XML output. It's probably not the best way to do this, and I still don't know exactly why it's happening, but at least I can get past the issue.

执行此操作后,XML输出中不再包含在其中包含数据的空白字段。这可能不是最好的方法,我仍然不知道为什么会发生这种情况,但至少我可以解决这个问题。

#7


-1  

Just delete all characters in the column and access will insert a null value for you if the coumn allows it.

只需删除列中的所有字符,如果coumn允许,访问权限将为您插入空值。

#1


4  

Are you talking about needing to do it in Datasheet view? If you needed to do it in an update query, you can do it like this:

您是否正在谈论需要在数据表视图中执行此操作?如果您需要在更新查询中执行此操作,则可以这样执行:

UPDATE test SET test.test = Null;

#2


4  

Does setting the "Allow zero length string" option in the table definition help? It may force an empty string to be interpreted as NULL.

在表定义中设置“允许零长度字符串”选项是否有帮助?它可能会强制将空字符串解释为NULL。

#3


2  

press ctrl-0 and a null is inserted.

按ctrl-0并插入一个null。

#4


2  

Deleting all the characters will work, but Access is a bit fickle. Hitting backspace or delete will not work unless there are characters in the field. I find it is best to enter a few characters, select all, and hit delete, change focus and change the record. After all the above, if you run a query looking for "is null" the record will be found.

删除所有字符都可行,但Access有点变幻无常。除非字段中有字符,否则按下退格键或删除将不起作用。我发现最好输入几个字符,选择全部,然后点击删除,更改焦点并更改记录。完成上述所有操作后,如果您运行查询“is null”,则会找到该记录。

#5


0  

I'm actually looking for a way for a layperson to do the entry directly in a table. In MSSQL you can simply press ctrl-0 and a null is inserted. Deleting all the characters doesn't appear to work. Instead of a null, you are left with an empty string. They are not treated the same by Access for export purposes.

我实际上正在寻找一种方式让外行人直接在表格中进行输入。在MSSQL中,您只需按ctrl-0并插入null。删除所有字符似乎不起作用。而不是null,你留下一个空字符串。出于出口目的,Access不会对它们进行相同的处理。

I think what I'm going to wind up doing is creating an xslt file to use during export that eliminates empty tags. That way the user can't really tell the difference.

我想我最终要做的是创建一个在导出过程中使用的xslt文件,以消除空标记。这样,用户无法真正区分。

It sure would be nice, though, to be able to key in a null.

但是,能够键入空值肯定会很好。

#6


0  

Ok, I don't think this is an easily solvable problem and my original question was a little off target. The problem isn't so much with nulls, although they are involved, as with the manner in which the table was originally created. If you use an xsd file to create your tables you plan on exporting, something happens under the hood in Access that causes those fields to be treated a little differently than fields created with the editors.

好吧,我不认为这是一个容易解决的问题,我原来的问题有点偏离目标。问题不在于null,尽管它们涉及到,就像最初创建表的方式一样。如果您使用xsd文件来创建计划导出的表,那么在Access中会发生一些事情,导致这些字段的处理方式与使用编辑器创建的字段略有不同。

The only solution I found was to create a new field in the table, rename the old field, copy the data from the old field to the new field and delete the old field.

我找到的唯一解决方案是在表中创建一个新字段,重命名旧字段,将数据从旧字段复制到新字段并删除旧字段。

After doing that, then blank fields that had data in them at one point are no longer included in the XML output. It's probably not the best way to do this, and I still don't know exactly why it's happening, but at least I can get past the issue.

执行此操作后,XML输出中不再包含在其中包含数据的空白字段。这可能不是最好的方法,我仍然不知道为什么会发生这种情况,但至少我可以解决这个问题。

#7


-1  

Just delete all characters in the column and access will insert a null value for you if the coumn allows it.

只需删除列中的所有字符,如果coumn允许,访问权限将为您插入空值。