Remove spaces

E

Ezekiël

Hi everyone,

Can somebody help me with a code that removes spaces within text.

I've many fields which i would like to examine for double values. The
problem is that there are sometimes spaces involved in text. When looking
for doubles, the result would be different.

E.g.:

value in field 1 = "too late"
value in field 2 = "toolate"
value in field 3 = " too late"

Can somebody help me to resolve this?
 
R

Randy Harris

Ezekiël said:
Hi everyone,

Can somebody help me with a code that removes spaces within text.

I've many fields which i would like to examine for double values. The
problem is that there are sometimes spaces involved in text. When looking
for doubles, the result would be different.

E.g.:

value in field 1 = "too late"
value in field 2 = "toolate"
value in field 3 = " too late"

Can somebody help me to resolve this?

The Replace function will remove the spaces for you.

?Replace(" too late ", " ", "")
"toolate"
 
M

Michel Walsh

Hi,



? Replace(" too late ", " ", "" )
toolate

Replace exists in VBA6, but with Access 2000, you have to rollup your
own cover function in VBA in order to be able to call it in a query. There
is no problem in 2002 or 2003.

For Access2000, define something like:

Public Function MyOwnReplace( Arg1 As String, Arg2 As string, Arg3 As
String ) As String
MyOwnReplace=Replace(Arg1, Arg2, Arg3)'
End Function



and use MyOneReplace(myFields, " ", "" ) in a query.


Hoping it may help,
Vanderghast, Access MVP
 
D

Douglas J. Steele

Shouldn't that be

Public Function MyOwnReplace( Arg1 As Variant, Arg2 As string, Arg3 As
String ) As String

to handle the possibility of a null field in what you're passing to the
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