Trim trailing spaces for name field in query

  • Thread starter Thread starter Jacqueline
  • Start date Start date
J

Jacqueline

I am trying to creat lables from a table. The query combines the first and
last name, but I need to trim the trailing spaces from the first name to
allow for only one space between the first and last name.

Here is how I created the name field:

LableName: [Emp_NAME_FIRST] & " " & [EMP_NAME_LAST]

However, because we set the first name field to 16 in the table to
accomendate different names the spaces also show up in the Lables: Example

KERRIE ABB
ROGER ALLEN

There are also trailing spaces on the last name as well but I am not so
worried about those.
Any help will be greatly appreciated.
Thanks
Jacqueline
 
Jacqeuline

Access will not normally store trailing spaces, even if you define the field
as text, 16. Are you using some other database to store your data and
linking to it via Access?

The way to do what you are looking for is to use the TRIM function:

LabelName: Trim([Emp_Name_First]) & " " & Trim([Emp_Name_Last])
 
Use the VBA function TRIM (to remove leading and trailing spaces) or RTrim (to
remove spaces at the end).

LableName: Trim([Emp_NAME_FIRST]) & " " & Trim([EMP_NAME_LAST])

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
Use the VBA function TRIM (to remove leading and trailing spaces) or RTrim (to
remove spaces at the end).

    LableName: Trim([Emp_NAME_FIRST]) & " " & Trim([EMP_NAME_LAST])

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County


I am trying to creat lables from a table. The query combines the first and
last name, but I need to trim the trailing spaces from the first name to
allow for only one space between the first and last name.
Here is how I created the name field:
LableName: [Emp_NAME_FIRST] & " " & [EMP_NAME_LAST]
However, because we set the first name field to 16 in the table to
accomendate different names the spaces also show up in the Lables: Example
KERRIE           ABB                      
ROGER            ALLEN
There are also trailing spaces on the last name as well but I am not so
worried about those.
Any help will be greatly appreciated.
Thanks
Jacqueline- Hide quoted text -

- Show quoted text -

Thank you John, saved me again! :)
Jacqueline
 
Jacqeuline

Access will not normally store trailing spaces, even if you define the field
as text, 16.  Are you using some other database to store your data and
linking to it via Access?

The way to do what you are looking for is to use the TRIM function:

LabelName: Trim([Emp_Name_First]) & " " & Trim([Emp_Name_Last])

----
HTH
Dale



Jacqueline said:
I am trying to creat lables from a table. The query combines the first and
last name, but I need to trim the trailing spaces from the first name to
allow for only one space between the first and last name.
Here is how I created the name field:
LableName: [Emp_NAME_FIRST] & " " & [EMP_NAME_LAST]
However, because we set the first name field to 16 in the table to
accomendate different names the spaces also show up in the Lables: Example
KERRIE           ABB                      
ROGER            ALLEN
There are also trailing spaces on the last name as well but I am not so
worried about those.
Any help will be greatly appreciated.
Thanks
Jacqueline- Hide quoted text -

- Show quoted text -

Thanks much, I used RTRIM and it worked !
Jacqueline
 
Back
Top