If you put the below function in a standard module it seems to work with all of the posted examples:
Code:
Function RemSpaces(strIn As String) As String
Dim n As Integer
bolEnd = False
For n = 1 To Len(strIn) - 1
If bolEnd = True Then Exit Function
'Debug.Print Mid(strIn, n, 1)
If Mid(strIn, n, 1) = " " Then
If Not IsNumeric(Mid(strIn, n + 1, 1)) Then
strIn = Replace(strIn, " ", "", , 1)
RemSpaces (strIn)
End If
End If
Next
Debug.Print strIn
bolEnd = True
End Function
You need Dim bolEnd at the top of the module, as in
Option Compare Database
Option Explicit
Dim bolEnd As Boolean
You could call it in testing as remspaces "262 74 RTC 7"
or put it in a calculated query field such as FieldAlias: RemSpaces ([queryFieldNameHere]) and it should return the "fixed" string to the query.
As some would say, 'there's your fish'.