Remove Spaces

A

Anna

I try to remove the spaces with that method but it still dont work.
When i run in the debug mode it still shows spaces.

If (bCorpFound) Then
strCorp = LTrim(strCorp)
strCorp = RTrim(strCorp)
strCorp = Replace(strCorp, " ", "")
' strCurrentChar = Right(strCorp, 1)
' Do While (strCurrentChar = " ")
' Advance 1 char, from right
' strCorp = Left(strCorp, (Len(strCorp) - 1))
' strCurrentChar = Right(strCorp, 1)
' Loop
End If

Thank You.
 
J

Jeff L

Is your code going into your IF statement? In other words, is
bCorpFound = True. By the way you can eliminate leading and trailing
spaces with one command - Trim(strCorp).
Another thing, what is strCorp? If it is a field on a form you need to
refer to it as Me.strCorp.

Hope that helps!
 
S

Steve Schapel

Jeff said:
Is your code going into your IF statement? In other words, is
bCorpFound = True.

I agree, I would suspect that bCorpFound is evaluating to False.
By the way you can eliminate leading and trailing
spaces with one command - Trim(strCorp).

.... and in any case would be handled by the Replace function. Really,
the procedure only needs:
If (bCorpFound) Then
strCorp = Replace(strCorp, " ", "")
End If
 
G

Guest

You only need one line of code to do it all:
strCorp = Trim(Replace(strCorp, " ", ""))

However, I would check my logic to see if bCorpFound is ever evaluating to
True. And quick and easy way to do this would be to set a breakpoint on this
line:
strCorp = LTrim(strCorp)

And run the code. My guess is, it will never break.
 

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