Oops, I should have changed the name of the function.
Code:
Function AddressBlock$(AName, Addr1, Addr2, City, State, email1, email2, Zip)
should be
Code:
Function AddressBlock(AName, Addr1, Addr2, City, State, email1, email2, Zip) As String
OK, I tested both of the functions. They both work (now).
Original
Code:
Function AddressBlock(AName, Addr1, Addr2, City, State, email1, email2, Zip) As String
Dim sA1 As String, sA2 As String, sA3 As String, sA4 As String
Dim sA5 As String, sA6 As String, sA7 As String, sA8 As String
Dim sCR As String
sCR = Chr(13) & Chr(10) 'Carriage return and line feed.
sA1 = IIf(ISB(AName), "", AName & sCR)
sA2 = IIf(ISB(Addr1), "", Addr1 & sCR)
sA3 = IIf(ISB(Addr2), "", Addr2 & sCR)
sA4 = IIf(ISB(City), "", City & sCR)
sA5 = IIf(ISB(State), "", State & sCR)
sA6 = IIf(ISB(email1), "", email1 & sCR)
sA7 = IIf(ISB(email2), "", email2 & sCR)
sA8 = "" & Zip
'Concatenate the strings.
AddressBlock = sA1 & sA2 & sA3 & sA4 & sA5 & sA6 & sA7 & sA8
End Function
Function ISB(V) As Integer
ISB = False ' set default return value
If IsNull(V) Or V = "" Then
ISB = True
End If
End Function
My re-write
Code:
Function AddressBlock(AName, Addr1, Addr2, City, State, email1, email2, Zip) As String
Dim sA1 As String, sA2 As String, sA3 As String, sA4 As String
Dim sA5 As String, sA6 As String, sA7 As String, sA8 As String
Dim sCR As String
sCR = Chr(13) & Chr(10) 'Carriage return and line feed.
' could use the following line instead
' sCR = vbNewLine
sA1 = IIf(Len(Nz(Trim(AName))) = 0, "", AName & sCR)
sA2 = IIf(Len(Nz(Trim(Addr1))) = 0, "", Addr1 & sCR)
sA3 = IIf(Len(Nz(Trim(Addr2))) = 0, "", Addr2 & sCR)
sA4 = IIf(Len(Nz(Trim(City))) = 0, "", City & sCR)
sA5 = IIf(Len(Nz(Trim(State))) = 0, "", State & sCR)
sA6 = IIf(Len(Nz(Trim(email1))) = 0, "", email1 & sCR)
sA7 = IIf(Len(Nz(Trim(email2))) = 0, "", email2 & sCR)
sA8 = "" & Zip
'Concatenate the strings.
AddressBlock = sA1 & sA2 & sA3 & sA4 & sA5 & sA6 & sA7 & sA8
End Function
You should have something that looks like:
=AddressBlock([AName],[Addr1],[Addr2],[City],[State],[email1],[email2],[Zip])
This is where you should have the names of the two email controls. The controls can be names anything... as long as they are in the correct place.
So if you have the two controls for the emails named "State1" and "State2", then the function call should be:
=AddressBlock([AName],[Addr1],[Addr2],[City],[State],[State1],[State2],[Zip])
If the two controls that have the email addresses are named "cat" and "dog", then the function call would look like:
=AddressBlock([AName],[Addr1],[Addr2],[City],[State],[Cat],[Dog],[Zip])