Trim() Problem

G

Guest

I'm pulling text data in from a DB2 table. Some of the text is coming with a
lot of spaces at the end. I have tried the Trim() function but it has no
effect. When I tried Replace([field],chr(32),"") this removed the spaces at
the end but it also removed the spaces between the words as well. Can anyone
suggest a solution? Thanks.

DK
 
D

Douglas J. Steele

It's possible that the string is text, followed by spaces, with some other
(perhaps non-visible) character at the end.

If you do Msgbox Asc(Right([NameOfField], 1)), what do you get?
 
G

Guest

Msgbox Asc(Right([NameOfField], 1)) returns a 0.

Douglas J. Steele said:
It's possible that the string is text, followed by spaces, with some other
(perhaps non-visible) character at the end.

If you do Msgbox Asc(Right([NameOfField], 1)), what do you get?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dan said:
I'm pulling text data in from a DB2 table. Some of the text is coming with
a
lot of spaces at the end. I have tried the Trim() function but it has no
effect. When I tried Replace([field],chr(32),"") this removed the spaces
at
the end but it also removed the spaces between the words as well. Can
anyone
suggest a solution? Thanks.

DK
 
D

Douglas J. Steele

That's the problem. 0 is a Null character, not a blank. Trim will stop at
the first non-blank character it sees.

See whether using Trim(Mid([NameOfField], Len([NameOfField]) - 1) works any
better.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dan said:
Msgbox Asc(Right([NameOfField], 1)) returns a 0.

Douglas J. Steele said:
It's possible that the string is text, followed by spaces, with some
other
(perhaps non-visible) character at the end.

If you do Msgbox Asc(Right([NameOfField], 1)), what do you get?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dan said:
I'm pulling text data in from a DB2 table. Some of the text is coming
with
a
lot of spaces at the end. I have tried the Trim() function but it has
no
effect. When I tried Replace([field],chr(32),"") this removed the
spaces
at
the end but it also removed the spaces between the words as well. Can
anyone
suggest a solution? Thanks.

DK
 

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