Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Do I have to worry about Access storing Trailing or leading spaces

1 view
Skip to first unread message

Steve Stad

unread,
Jan 6, 2010, 9:45:01 PM1/6/10
to
Do I have to worry about Access storing Trailing or leading spaces or do I
need code such as......

Private Sub NAME_AfterUpdate()
Me.[NAME] = Trim(Me.[NAME])
End Sub


Stuart McCall

unread,
Jan 6, 2010, 10:05:34 PM1/6/10
to
"Steve Stad" <Stev...@discussions.microsoft.com> wrote in message
news:0171C09C-961F-410F...@microsoft.com...

Trailing spaces are stripped out by Access, but leading spaces aren't. So
you can use LTrim instead of Trim (slightly faster, if only noticeable in
long loops).


Steve Stad

unread,
Jan 6, 2010, 11:05:01 PM1/6/10
to
Thanks Stuart - but are you aware of being able to copy/paste a word or
string with a trailing space from an external source (e.g., web page, etc)
into access?

"Stuart McCall" wrote:

> .
>

Stuart McCall

unread,
Jan 6, 2010, 11:29:41 PM1/6/10
to
"Steve Stad" <Stev...@discussions.microsoft.com> wrote in message
news:2B398B0D-92DF-4061...@microsoft.com...

I wasn't aware of that feature. I take it you've discovered this to be the
case. In that case yes, Trim is the correct function to use.


Dirk Goldgar

unread,
Jan 7, 2010, 2:52:21 PM1/7/10
to
"Steve Stad" <Stev...@discussions.microsoft.com> wrote in message
news:2B398B0D-92DF-4061...@microsoft.com...

> Thanks Stuart - but are you aware of being able to copy/paste a word or
> string with a trailing space from an external source (e.g., web page, etc)
> into access?


I think that if you copy and paste into a text box or a cell of a datasheet,
trailing spaces will be removed. However, that is true for the character
that Access recognizes as a space, Chr(32), and would not be true for some
other characters that may appear to be spaces; for example, Chr(160).
However, Trim() won't remove such characters, either.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

Steve Stad

unread,
Jan 9, 2010, 7:31:02 PM1/9/10
to
Thanks Dirk,
I must have encountered a Chr(160) space in the past. I eliminated these
with a validation rule in the tbl design - and never knew the difference
between chr(160) and chr(32).
0 new messages