How omit Address line 2 in mailing labels?

G

Guest

I have a report that prints mailing labels. There are two address lines:
Address1 and Address2. When Address2 is blank I want to omit the line. I have
Can Shrink and CanGrow both set to YES. I also tried the following code. So
far nothing has worked.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Nz(Trim(Me.Address2), "") = "" Then
Me.Address2.Visible = False
Else
Me.Address2.Visible = True
End If
End Sub

The control does have Format set to > I dont know if that is a factor.
 
M

Marshall Barton

mscertified said:
I have a report that prints mailing labels. There are two address lines:
Address1 and Address2. When Address2 is blank I want to omit the line. I have
Can Shrink and CanGrow both set to YES. I also tried the following code. So
far nothing has worked.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Nz(Trim(Me.Address2), "") = "" Then
Me.Address2.Visible = False
Else
Me.Address2.Visible = True
End If
End Sub


You must also make sure the section's anShrink property is
set to Yes.

If you have other controls next to the address controls, the
section can not shrink one side and not shrink the other
side. In this kind of situation, you can use a single text
box with a careful mix of the two concatenation operators:

=fullname & (Chr(13) + Chr(10) + address1) & (Chr(13) +
Chr(10) + address2) & Chr(13) + Chr(10) & City & ", " &
State & " " & Zip
 
G

Guest

Thanks for the response.
I'm not sure what the significance of mixing '&' and '+" operators is but I
tried your solution. I cannot get it to display anything beyond the first
address line. I tried various combinations of the operators and the
parentheses but nothing seems to work. What could I be doing wrong?
 
M

Marshall Barton

Hard to tell what you might have done wrong without seeing
it.

Are you sure the text box has it's CanGrow property set to
Yes?

I'm pretty sure I have the + & () stuff in the right places,
nut FYI, the + operator also performs concatenation on text
values. The difference is that + propogates Null while &
does not. I.e.
"abc" & Null is "abc"
but
"abc" + Null is Null
 
G

Guest

I did some more checking and it appears that as soon as I concatenate the
chr(10), everything to the right of it disappears.
 
M

Marshall Barton

That is not normal, either something is drastically out of
whack or you did something wrong. Please post a Copy/Paste
of the expression you used.

Did you double check that the text box's CanGrow property is
set to Yes?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top