Access 2003 Query Is Finding Fields With Non-Alphanumeric Data

I can't seem to find an Access 2003  function that will remove all non-alphanumeric data from a field. My query is unable to summarize data because fields that contain identical data are not being properly Grouped because one of them contains what looks like boxes/squares at the end/far right of the field; I assume some type of carriage return or other non-alphanumeric placeholder.

I've already tried using the Trim function but it fails to eliminate the oddball data.

I should mention that this field is keyed by a user but is part of an ERP system so it may have also been ported or otherwise manipulated by one of the programs in our business system. Our system is written in Visual Basic and on top of an Access database if that helps.

Let me know if you need more information.
Who is Participating?
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
try doing this, instead of Trim

replace(replace(replace([fieldName],chr(13) & chr(10),""),chr(13),""),chr(10),"")


trim(replace(replace(replace([fieldName],chr(13) & chr(10),""),chr(13),""),chr(10),""))
Rey Obrero (Capricorn1)Commented:
if that does not work, you will need VBA codes to determine those non printable characters and remove them.
Try this in place of the Trim() function.
Function CleanUpString(strInText As String) As String
    Dim p As Integer
    p = Len(strInText)
    If p = 0 Then
        Exit Function
    End If
    Do While Asc(Mid(strInText, p)) < Asc(" ")
        p = p - 1
        If p = 0 Then
            Exit Function
        End If
    CleanUpString = Trim(Left(strInText, p))
End Function

Open in new window

slamondAuthor Commented:
This simple formula works.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.