I don't like this expression for a couple of reasons
IIf(Nz([Part_Number],"0")="0",0,CLng(Mid([Part_Number],3,Len([Part_Number])-2)))
I don't get the point of 'convert a null to 0 but make 0 a text data type, then compare it to 0 that is also a text data type, and if equal, return 0, which is a number. As for the rest, I skimmed over all the prior posts, but didn't see anything that indicates why you're wanting all of the number value except for the last 2 characters/digits. After composing this part, I see you've replied and I responded to the comment at the end of this post. Seems to me you don't quite grasp what the expression does, but I could be wrong. You might want to review its syntax. However, seems to me that even if that is what you want, let's look at the logic by evaluating the parts. I replaced the field reference with Null for cases where it is Null:
Code:
IIf(Nz([This Is Null],"0")="0",0,CLng(Mid([This Is Null],3,Len([This Is Null])-2)))
IIf("0")="0",0,CLng(Mid([This is Null],3,Len([This is Null])-2))) *so IIf will return 0 and Mid will return Null
IIf("0")="0",0,CLng(Null)-2
Pretty sure you cannot convert Null to a Long, which is likely at least 1 reason for #Error. I think the expression is also too complex. Rather than returning a text zero from Nz then comparing it to "0" just to arrive at using 0, just IIf(Is Null([Part_Number]),0...
The first one was hard-coded for 2 characters ONLY using the Mid function to strip the first 2 characters:Mid([Part_Number],3,Len([Part_Number])-2).
No, that says start at position 3, go to the right and return all the characters exept for the last 2.
I haven't kept up with the various db attachments, so I shouldn't suggest a fix or any other possible approach at this point. Maybe you'll fix it before I have the chance to try anything.