
Originally Posted by
Tom Jones
@snb,
Highlight this line:
.Fields("S") = Replace(sn(j, 1), .Fields("N"), "")
I think it's to do with the original ending in a zero. In the following, zzz is your recordset object:
?sn(j, 1)
FVR25180
?StrReverse(sn(j, 1))
08152RVF
?Val(StrReverse(sn(j, 1)))
8152
?StrReverse(Val(StrReverse(sn(j, 1))))
2518
?zzz.Fields("N")
2518
?Replace(sn(j, 1), zzz.Fields("N"), "")
FVR0
I put it in code tags to try to preserve spaces/invisible characters.
Although the last command produces a string, it's the execution of:
.Fields("S") = Replace(sn(j, 1), .Fields("N"), "")
which throws an error.
Doing a Val on a string starting with zero, the zero is ignored.
Still don't know why it throws an error though…
edit: could it be because it's trying to put more than a 3-character string in a field with a defined size of 3?