odin1701
04-25-2007, 06:55 AM
I have a string, which is an account number. ex: 111222233333
When I get the account number from the field in the form I get this as a result:
" 111222233333"
It has a space at the beginning. However, when I try to do any of the following, it still has a leading space:
Trim(acctNum.value)
LTrim(acctNum.value)
Or if I define a string
Dim strAcct as String
stracct = acctNum.value
strAcct = Trim(strAcct)
Still the leading space. What am I doing wrong?
Is there a function that I can use to just delete the first character, whatever that character is. Maybe it isn't a space somehow??
I'm also confused as to why there is a leading space when it doesn't show in the field on the form or the table the data is in. I did not make this database, I'm just fixing it (ugh).
KeithG
04-25-2007, 06:57 AM
Interesting I don't know what the problem would be. Try using the replace funtion to replace the blank space with nothing
Replace("String"," ","")
odin1701
04-25-2007, 07:04 AM
Interesting I don't know what the problem would be. Try using the replace funtion to replace the blank space with nothing
Replace("String"," ","")
Well tried that and there is still a space or blank or something in front. I don't understand why though.
odin1701
04-25-2007, 07:06 AM
Also, I pulled a number from a different field and it also has a leading space. This makes no sense.
RuralGuy
04-25-2007, 07:07 AM
Put in a diagnostic message box:
MsgBox "1st character code is [" & Asc([YourString]) & "]"
...the Asc() function looks at the 1st character in the string and a space would be 32 decimal.
JohnLee
04-25-2007, 07:21 AM
Put in a diagnostic message box:
MsgBox "1st character code is [" & Asc([YourString]) & "]"
...the Asc() function looks at the 1st character in the string and a space would be 32 decimal.
Hi,
Could I make a suggestion, I have found sometimes for some reason in the underlaying table in the field concerned that sometimes people set the default value to " ", which forces a space no matter what, You may have already checked this out, but sometime the simple things get overlooked.
John
odin1701
04-25-2007, 07:41 AM
Put in a diagnostic message box:
MsgBox "1st character code is [" & Asc([YourString]) & "]"
...the Asc() function looks at the 1st character in the string and a space would be 32 decimal.
Cool....I did that. It's 160.
So I did:
acctNum = Replace(acctNum, Chr(160), "")
That fixed it. I still have no clue how that character gets in there. I already did check the defaul value for that field and there's nothing in there that would cause it.
BrettStah
04-25-2007, 07:48 AM
CHR(160) is a non-breaking space character, commonly used on HTML pages.
odin1701
04-25-2007, 07:55 AM
CHR(160) is a non-breaking space character, commonly used on HTML pages.
That is very very odd...this has no HTML code or anything to do with website stuff at all.
BrettStah
04-25-2007, 07:59 AM
That is very very odd...this has no HTML code or anything to do with website stuff at all.
That is just one of the common places it is used. It is by no means limited to HTML pages, as you've discovered. :)