如果字段为空,Access Replace函数将出错



我有一个包含以下内容的查询:

Field1: Replace([Field1],"ü",", ")

如果字段1中有内容,这将非常有效。Field1中的数据通常看起来像1ü2、0ü0、1ü1等。然而,如果一条记录在Field1中什么都没有,我会得到以下错误:

This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables.

如果我将字段更改为Field1: Field1,则查询运行时不会出现错误。有没有办法处理字段1为空的可能性?

谢谢!

您需要处理Field1包含null值的可能性。

Replace函数的第一个参数不能包含null值,所以您使用nz函数将所有null值转换为其他值,在这种情况下,它将是""

Field1: Replace(nz([Field1],""),"ü",", ")

最新更新