Remove leading spaces

  • Thread starter Thread starter EllenM
  • Start date Start date
E

EllenM

Sometimes when importing a table from Excel, a leading space gets inserted in
the field, which messes up queries. I tried to remove this space with a find
and replace (this column shouldn't have had any spaces), but to no avail. I
wound up removing them by hand.

Is there an easy way to remove leading spaces in a field?

Thanks in advance,
Ellen
 
You could run an Update query using the LTrim Function

UPDATE tblMyTable SET MyField = LTrim("MyField");

LTrim - removes leading spaces
RTrim - removes trailing spaces
Trim - removes both leading and trailing spaces
 
DON'T, that query would be dangerous.
UPDATE tblMyTable SET MyField = LTrim("MyField");
This would end up with MyField containing the value "MyField".

Try:
UPDATE tblMyTable SET MyField = LTrim([MyField]);
 
Thanks for catching my mistake Duane. Not sure what I was thinking
there.
--
_________

Sean Bailey


Duane Hookom said:
DON'T, that query would be dangerous.
UPDATE tblMyTable SET MyField = LTrim("MyField");
This would end up with MyField containing the value "MyField".

Try:
UPDATE tblMyTable SET MyField = LTrim([MyField]);

--
Duane Hookom
Microsoft Access MVP


Beetle said:
You could run an Update query using the LTrim Function

UPDATE tblMyTable SET MyField = LTrim("MyField");

LTrim - removes leading spaces
RTrim - removes trailing spaces
Trim - removes both leading and trailing spaces
 
Back
Top