Private Sub NAME_AfterUpdate()
Me.[NAME] = Trim(Me.[NAME])
End Sub
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).
"Stuart McCall" wrote:
> .
>
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.
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)