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  

How to remove spaces from a report if a field is left blank



 
 
Thread Tools Display Modes
  #1  
Old August 4th, 2009, 05:00 PM posted to microsoft.public.access.reports
JamiLea
external usenet poster
 
Posts: 3
Default How to remove spaces from a report if a field is left blank

I am creating a report that will print the letters for a function within my
company. I have created a report for each letter. I need to know how to
remove the spaces that are in the print preview when a certain field is not
filled out. What also makes this more difficult is the text box itself. See
the text box below. Does anyone know how to remove the spaces?

Text Box....=[AddlSent] & " " & [AddlSent2] & " " & [AddlSent3]

  #2  
Old August 4th, 2009, 05:45 PM posted to microsoft.public.access.reports
fredg
external usenet poster
 
Posts: 4,386
Default How to remove spaces from a report if a field is left blank

On Tue, 04 Aug 2009 16:00:58 GMT, JamiLea wrote:

I am creating a report that will print the letters for a function within my
company. I have created a report for each letter. I need to know how to
remove the spaces that are in the print preview when a certain field is not
filled out. What also makes this more difficult is the text box itself. See
the text box below. Does anyone know how to remove the spaces?

Text Box....=[AddlSent] & " " & [AddlSent2] & " " & [AddlSent3]


= [AddSent] & (" "+[AddSent2]) & (" "+[AddSent3])
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #3  
Old August 4th, 2009, 06:18 PM posted to microsoft.public.access.reports
John Spencer
external usenet poster
 
Posts: 7,815
Default How to remove spaces from a report if a field is left blank

Fred's solution works if the Add1Sent2 and Add1Sent3 fields null. If the
field values are zero-length strings it fails. In my databases Fred's
solution would work since I don't allow zero-length strings. If his solution
fails then try the more complex expression below.

=[AddlSent] & IIF(Len(Add1Sent2 & "")=0,""," " & [AddlSent2]) &
IIF(Len(Add1Sent3 & "")=0,""," " & [AddlSent3])

Of course, in some databases you can store fixed length text fields and any
unused part of the length is automatically padded with spaces. This adds one
more level of complexity to the expression.

=[AddlSent] & IIF(Len(Trim(Add1Sent2) & "")=0,""," " & Trim([AddlSent2])) &
IIF(Len(Trim(Add1Sent3) & "")=0,""," " & Trim([AddlSent3]))

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

fredg wrote:
On Tue, 04 Aug 2009 16:00:58 GMT, JamiLea wrote:

I am creating a report that will print the letters for a function within my
company. I have created a report for each letter. I need to know how to
remove the spaces that are in the print preview when a certain field is not
filled out. What also makes this more difficult is the text box itself. See
the text box below. Does anyone know how to remove the spaces?

Text Box....=[AddlSent] & " " & [AddlSent2] & " " & [AddlSent3]


= [AddSent] & (" "+[AddSent2]) & (" "+[AddSent3])

  #4  
Old August 4th, 2009, 07:20 PM posted to microsoft.public.access.reports
JamiLea
external usenet poster
 
Posts: 3
Default How to remove spaces from a report if a field is left blank

thank you very much! That worked perfectly

John Spencer wrote:
Fred's solution works if the Add1Sent2 and Add1Sent3 fields null. If the
field values are zero-length strings it fails. In my databases Fred's
solution would work since I don't allow zero-length strings. If his solution
fails then try the more complex expression below.

=[AddlSent] & IIF(Len(Add1Sent2 & "")=0,""," " & [AddlSent2]) &
IIF(Len(Add1Sent3 & "")=0,""," " & [AddlSent3])

Of course, in some databases you can store fixed length text fields and any
unused part of the length is automatically padded with spaces. This adds one
more level of complexity to the expression.

=[AddlSent] & IIF(Len(Trim(Add1Sent2) & "")=0,""," " & Trim([AddlSent2])) &
IIF(Len(Trim(Add1Sent3) & "")=0,""," " & Trim([AddlSent3]))

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

I am creating a report that will print the letters for a function within my
company. I have created a report for each letter. I need to know how to

[quoted text clipped - 5 lines]

= [AddSent] & (" "+[AddSent2]) & (" "+[AddSent3])


 




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 08:32 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.