A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Remove Spaces



 
 
Thread Tools Display Modes
  #1  
Old August 21st, 2006, 02:39 PM posted to microsoft.public.access.forms
Anna
external usenet poster
 
Posts: 66
Default 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  
Old August 21st, 2006, 03:02 PM posted to microsoft.public.access.forms
Jeff L
external usenet poster
 
Posts: 448
Default 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  
Old August 21st, 2006, 04:03 PM posted to microsoft.public.access.forms
Steve Schapel
external usenet poster
 
Posts: 1,422
Default 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  
Old August 21st, 2006, 05:04 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:37 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.