trim functions

J

Jeff

i was wondering if there was a function that was able to remove spaces inside
of a string, basically the opposite of a trim function. i have data that i
need to import into a database that has to fit the field size. if there is
no such funtion, i could write one, i was just wondering if access had this
already.

thanks in advance
 
D

Dirk Goldgar

Jeff said:
i was wondering if there was a function that was able to remove
spaces inside of a string, basically the opposite of a trim function.
i have data that i need to import into a database that has to fit the
field size. if there is no such funtion, i could write one, i was
just wondering if access had this already.

thanks in advance

There's no such built-in function. If you want to remove all spaces in
the input string, not just doubled-up spaces, you can use the Replace()
function to replace the space character with a zero-length string.
 
K

Ken Snell [MVP]

No, but you can use the Replace function to replace a blank space with an
empty string.
 
R

Roger Carlson

Well, there is a Replace function which will replace any instance of a group
of one or more characters with another. If you tell it to replace " " with
"", that usually works. For instance:

Sub test()
dim myString as String
myString = "aa bb cc"
Debug.Print Replace(myString, " ", "")
End Sub

will return "aabbcc"

--
--Roger Carlson
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
Top