A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Problem with the TRIM command



 
 
Thread Tools Display Modes
  #1  
Old January 8th, 2010, 03:50 PM posted to microsoft.public.access.reports
FMO902
external usenet poster
 
Posts: 3
Default Problem with the TRIM command

I have four fields (First_Name, MI, Last_Name, Suffix) that I am trying to
trim so that they will appear without spaces on a report. When I do a
combined string (=RTrim([First_Name])+" "+[MI]+" "+Trim([Last_Name])+"
"+[Suffix]) I run into problems when any one of the fields is blank. Nothing
will print. As long as all four fields contain data it will print. Problem is
that only a few records have data in all four fields.

When I separate out the fields into four separate controls on the report, I
cant get the TRIM function to work and there are spaces between the conrols.

Any idea? I think I am missing somehting simple here.

Thanks
Rob

  #2  
Old January 8th, 2010, 04:27 PM posted to microsoft.public.access.reports
Duane Hookom
external usenet poster
 
Posts: 7,177
Default Problem with the TRIM command

Typically with Access you don't need to use Trim(). Also, the & and + have
different results. + will propogate nulls.

Try:
=[First_Name] & " " + [MI] & " " + [Last_Name] & " " + [Suffix]

--
Duane Hookom
Microsoft Access MVP


"FMO902" wrote:

I have four fields (First_Name, MI, Last_Name, Suffix) that I am trying to
trim so that they will appear without spaces on a report. When I do a
combined string (=RTrim([First_Name])+" "+[MI]+" "+Trim([Last_Name])+"
"+[Suffix]) I run into problems when any one of the fields is blank. Nothing
will print. As long as all four fields contain data it will print. Problem is
that only a few records have data in all four fields.

When I separate out the fields into four separate controls on the report, I
cant get the TRIM function to work and there are spaces between the conrols.

Any idea? I think I am missing somehting simple here.

Thanks
Rob

  #3  
Old January 8th, 2010, 08:01 PM posted to microsoft.public.access.reports
FMO902
external usenet poster
 
Posts: 3
Default Problem with the TRIM command

Duane:
That did the trick!! Thanks. Now for my education, can you explain the
difference between the '&' and the '+' operators and also can you explain why
the TRIM command is not needed here?

Thanks
Rob

"Duane Hookom" wrote:

Typically with Access you don't need to use Trim(). Also, the & and + have
different results. + will propogate nulls.

Try:
=[First_Name] & " " + [MI] & " " + [Last_Name] & " " + [Suffix]

--
Duane Hookom
Microsoft Access MVP


"FMO902" wrote:

I have four fields (First_Name, MI, Last_Name, Suffix) that I am trying to
trim so that they will appear without spaces on a report. When I do a
combined string (=RTrim([First_Name])+" "+[MI]+" "+Trim([Last_Name])+"
"+[Suffix]) I run into problems when any one of the fields is blank. Nothing
will print. As long as all four fields contain data it will print. Problem is
that only a few records have data in all four fields.

When I separate out the fields into four separate controls on the report, I
cant get the TRIM function to work and there are spaces between the conrols.

Any idea? I think I am missing somehting simple here.

Thanks
Rob

  #4  
Old January 8th, 2010, 08:17 PM posted to microsoft.public.access.reports
Duane Hookom
external usenet poster
 
Posts: 7,177
Default Problem with the TRIM command

Access doesn't store trailing spaces so Trim() generally is a waste of time.
The difference between + and & is that they can both be used to concatenate
text but the + will propogate a Null
Null + "Rob" = Null
Null & "Rob" = "Rob"
Null + " " & "Rob" = "Rob"
Null & " " & "Rob" = " Rob"

--
Duane Hookom
Microsoft Access MVP


"FMO902" wrote:

Duane:
That did the trick!! Thanks. Now for my education, can you explain the
difference between the '&' and the '+' operators and also can you explain why
the TRIM command is not needed here?

Thanks
Rob

"Duane Hookom" wrote:

Typically with Access you don't need to use Trim(). Also, the & and + have
different results. + will propogate nulls.

Try:
=[First_Name] & " " + [MI] & " " + [Last_Name] & " " + [Suffix]

--
Duane Hookom
Microsoft Access MVP


"FMO902" wrote:

I have four fields (First_Name, MI, Last_Name, Suffix) that I am trying to
trim so that they will appear without spaces on a report. When I do a
combined string (=RTrim([First_Name])+" "+[MI]+" "+Trim([Last_Name])+"
"+[Suffix]) I run into problems when any one of the fields is blank. Nothing
will print. As long as all four fields contain data it will print. Problem is
that only a few records have data in all four fields.

When I separate out the fields into four separate controls on the report, I
cant get the TRIM function to work and there are spaces between the conrols.

Any idea? I think I am missing somehting simple here.

Thanks
Rob

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:53 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.