Solved

Skipping a line for null data

Posted on 2012-12-21
5
279 Views
Last Modified: 2013-03-06
I am creating a report in Access to show a list of Contact Names, addresses, phone #s, etc.  I have 2 lines for Address and then Address2 and I am trying to not have a blank line show for people who do not have an Address2.  I'm sure this is simple I just forgot how to do it.
0
Comment
Question by:apsonline
5 Comments
 
LVL 4

Expert Comment

by:rshq
ID: 38713981
Hi
 Maybe you can use shrink.
0
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 167 total points
ID: 38714540
The Can Shrink property for your Address2 textbox will work provided that you don't have any controls next to that textbox.  If you do have any other controls horizontally lined up with it, the Can Shrink property will not work.

To avoid problems with skipped lines, I generally use one textbox for both address lines, and set it's control source property as follows (including the = sign):

= Address & iif("" & Address2 = "", "", Chr(13) & Chr(10)  & Address2)

Open in new window


If
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 167 total points
ID: 38714942
Try this expression in a textbox:
=[LName] & ', '+[FName] & '
'+[Address1] & '
'+[Address2] & '
'+[City] & ', '+[State] & ' '+[Zip] & '
'+'Home: '+[HomePhone] & '
'+'Cell: '+[CellPhone]


At the end of each line (after each single quote), add a carriage return using CTRL+ENTER.  The + sign concatenates the fields and if a field is null it erases any concatenated strings including carriage returns.  So if the only fields with data were First & Last Name, City, and CellPhone, it would show up as:

Skywalker, Luke
San Diego
Cell: 123-456-7890


You can learn more about this concatenation style form harfang's article:
Concatenation in Access Reports (and Forms)
0
 
LVL 31

Assisted Solution

by:Helen_Feddema
Helen_Feddema earned 166 total points
ID: 38716081
The best thing (though maybe not practical at this point) would be to eliminate the Address2 field entirely.  There is no need for a field for each line of an address, since you can enter multiple address lines into one field in Access.  If that is not practical, you can use something like the following in a query expression:

Address: IIf(Nz([Address2])<>"",[Address1] & Chr(13) & Chr(10) & [Address2],[Address1])
0
 

Author Closing Comment

by:apsonline
ID: 38959414
I tried all three of these and they all worked somewhat, however the =Trim command, which was not suggested worked best.  Thanks to everyone for their efforts.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now