Linking on Two Fields with 0s Trimmed - Access

时间:2017-06-12 16:58:52

标签: ms-access

I have two separate queries which trim the 0s from two separate tables using the following functions

Replace(LTrim(Replace(Nz([03_Account_Matrix].[PORT_ACCT_DDA]),"0"," "))," ","0")

The Nz is because there are some nulls in the first table.

Replace(LTrim(Replace(Nz([04_Balance].[Account]),"0"," "))," ","0")

The reason for this is because they might be the same account, but have a different number of leading 0s (Terrible design, I know).

An example number is 00040007613 and 0040007613 which are the same and get trimmed to be so.

However, when I linked the trimmed queries on this account number, there are no results; although, in the queries, they are the same value. Why is this occurring? My best guess is because the strings might contain a different number of spaces....?

1 个答案:

答案 0 :(得分:0)

是的,不同数量的空格与不同数量的零相同。你为什么用空格代替?为什么不只是空字符串?

基于提供的示例:

Replace("00040007613","0","") = Replace("0040007613","0","")

但请考虑:

Format("00040007613","00000000000") = Format("0040007613","00000000000")