Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I ignore blank values when printing an address

Status
Not open for further replies.

twiggymates

Programmer
Dec 20, 2003
7
0
0
GB
Hello there

I have a report that prints an address of a customer, pulling each individual part of the address from the main table in the form Customer Name, Customer Address Line 1, Customer Address Line 2, Customer Address Line 3, Customer Postcode.

Sometimes several of the values can be blank and therefore when the report prints, it shows blank spaces in between, say for example, the name and postcode. Is there any way of ignoring blank lines completely and shifting up the next control to fill the space? I've tried can shrink but this seems only to work if all fields are pulled to one text box.

Cheers
 
Can Shrink will work reliably as long as there are no controls to the left or right of the "can shrink" control. This only shrinks text boxes with Null values.

If you give us a little more info on your control sources, we might be able to provide more direction.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
What you might want to do is clean up the data first. You can run a query which updates eg AddressLine2 to AddressLine3 if AddressLine2 is blank or null. Then repeat this for Line 1 and 2. You get the idea. A handful of simple queries will shuffle up the data to remove empty fields - all without VBA.

 
Try this: Use the + NULL Property to Stop printing:

Use a Text Box, Can Shrink = True, Can Grow = True, Control Source = FixLine(" ") & FixLine([Customer Name]) & (", " + Fixline([Customer Address Line 1])) & (", " + FixLine([Customer Address Line 2])) & (", " + Fixline([Customer Address Line 3])) & (" " + [Customer Post Code]))



Public Function FixLine(VarVal As Variant) As Variant
FixLine = VarVal + vbCrLf
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top