concatenate names - remove blanks

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm running thisquery to concatenate last and first names into one field.
How can I get the blanks out after last name? Thanks for any ideas.

SELECT [pt_last] & ', ' & [pt_first]
FROM batches;

The results look like:

SMITH , EARL
 
Trim it.

SELECT Trim([pt_last]) & ', ' & [pt_first]
FROM batches;
Trims both leading and trailing spaces.

If you are interested trimming the leading spaces alone use LTRIM( ).
For trailing spaces alone use RTRIM( ).

Thanks,
Saran.
 
In most Access data, you would not have to remove the blanks since
Access/Jet doesn't store blanks on the right. If you are getting blanks, I
assume you data is from another database application. Try use the Trim()
function:

SELECT Trim([pt_last]) & ', ' & [pt_first] As PtFirstLast
FROM batches;
 
Thanks, that is just what I needed!

Duane Hookom said:
In most Access data, you would not have to remove the blanks since
Access/Jet doesn't store blanks on the right. If you are getting blanks, I
assume you data is from another database application. Try use the Trim()
function:

SELECT Trim([pt_last]) & ', ' & [pt_first] As PtFirstLast
FROM batches;

--
Duane Hookom
MS Access MVP

denise said:
I'm running thisquery to concatenate last and first names into one field.
How can I get the blanks out after last name? Thanks for any ideas.

SELECT [pt_last] & ', ' & [pt_first]
FROM batches;

The results look like:

SMITH , EARL
 
Back
Top