Remove nonprintable characters from text in Access

W

Wendy DePalma

How to I remove nonprintable character from a text field in MS Access (2003)?
I found the CLEAN function that works in Excel, but it is not available
Access.
 
L

louisjohnphillips

How to I remove nonprintable character from a text field in MS Access (2003)?
 I found the CLEAN function that works in Excel, but it is not available
Access.

Could you write a vba function like this:


Private Clean( sInputString as string ) as string

Dim nLen, nIndex as integer
Dim sOutputString as string
Dim sSingleChar as string
Dim nAsciiValue as integer

sOutputString = ""

nLen = Len( sInputString )

for nIndex = 1 to nLen

sSingleChar = Mid( sInputString, nIndex, 1 )
nAsciiValue = asc( sSingleChar )
if nAsciiValue < 32 or nAsciiValue > 128 then
' These are non-printable characters
else
sOutputString = sOutputString & sSingleChar
end if
next

Clean = sOutputString

end function

Then write an update statement like

Update table1
set column1 = Clean( column1 )

Would this work?
 
W

Wendy DePalma

Wendy DePalma said:
How to I remove nonprintable character from a text field in MS Access (2003)?
I found the CLEAN function that works in Excel, but it is not available
Access.

The vba function worked like a charm. I just had to replace 'Private' with 'Function'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top