If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Remove Spaces
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. |
#2
|
|||
|
|||
Remove Spaces
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! Anna wrote: 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. |
#3
|
|||
|
|||
Remove Spaces
Jeff L wrote: 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 -- Steve Schapel, Microsoft Access MVP |
#4
|
|||
|
|||
Remove Spaces
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. "Anna" wrote: 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. |
Thread Tools | |
Display Modes | |
|
|