concatenate names - remove blanks

D

denise

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
 
S

Saran

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.
 
D

Duane Hookom

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;
 
D

denise

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
 
Top