This is a function i have written to align a series of addresses for printing labels.
However, for some reason the post code (A8) is not being moved up with the other address lines.
I can't for the life of me work out why. I need somebody with fresh eyes HELP!!
I am running the function on an access report in a text box which has the following code:
(a1 - a8 are the address fields supplied from an access query)
However, for some reason the post code (A8) is not being moved up with the other address lines.
I can't for the life of me work out why. I need somebody with fresh eyes HELP!!
Code:
Function AddressLabels(ADD1, ADD2, ADD3, ADD4, ADD5, TOWN, COUNTRY, PCODE) As String On Error GoTo AddressLabels_err Dim A1, A2, A3, A4, A5, A6, A7, A8 As String Dim i As Integer A1 = ADD1 A2 = ADD2 A3 = ADD3 A4 = ADD4 A5 = ADD5 A6 = TOWN A7 = COUNTRY A8 = PCODE For i = 1 To 7 If IsNull(A2) Then A2 = A3 A3 = Null Else A2 = A2 A3 = A3 End If If IsNull(A3) Then A3 = A4 A4 = Null Else A3 = A3 A4 = A4 End If If IsNull(A4) Then A4 = A5 A5 = Null Else A4 = A4 A5 = A5 End If If IsNull(A5) Then A5 = A6 A6 = Null Else A5 = A5 A6 = A6 End If If IsNull(A6) Then A6 = A7 A7 = "" Else A6 = A6 A7 = A7 End If If IsNull(A7) Then A7 = A8 A8 = "" Else A7 = A7 A8 = A8 End If Next i AddressLabels = A1 & Chr(13) & Chr(10) & A2 & Chr(13) & Chr(10) & A3 & Chr(13) & Chr(10) & A4 & Chr(13) & Chr(10) & A5 & Chr(13) & Chr(10) & A6 & Chr(13) & Chr(10) & A7 & Chr(13) & Chr(10) & A8 Exit Function AddressLabels_err: AddressLabels = "" Exit Function End Function
Code:
=addresslabels([a1],[a2],[a3],[a4],[a5],[a6],[a7],[a8])
Comment