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!! - 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
I am running the function on an access report in a text box which has the following code: - =addresslabels([a1],[a2],[a3],[a4],[a5],[a6],[a7],[a8])
(a1 - a8 are the address fields supplied from an access query)
3 1400
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!! - 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
I am running the function on an access report in a text box which has the following code: - =addresslabels([a1],[a2],[a3],[a4],[a5],[a6],[a7],[a8])
(a1 - a8 are the address fields supplied from an access query)
Hi
Would this be better - Function AddressLabels(ADD1, ADD2, ADD3, ADD4, ADD5, TOWN, COUNTRY, PCODE) As String
-
-
On Error GoTo AddressLabels_err
-
-
AddressLabels = ADD1
-
-
If ADD2 & "" <> "" Then AddressLabels = AddressLabels & Chr(13) & Chr(10) & ADD2
-
If ADD3 & "" <> "" Then AddressLabels = AddressLabels & Chr(13) & Chr(10) & ADD3
-
If ADD4 & "" <> "" Then AddressLabels = AddressLabels & Chr(13) & Chr(10) & ADD4
-
If ADD5 & "" <> "" Then AddressLabels = AddressLabels & Chr(13) & Chr(10) & ADD5
-
If TOWN & "" <> "" Then AddressLabels = AddressLabels & Chr(13) & Chr(10) & TOWN
-
If COUNTRY & "" <> "" Then AddressLabels = AddressLabels & Chr(13) & Chr(10) & COUNTRY
-
If PCODE & "" <> "" Then AddressLabels = AddressLabels & Chr(13) & Chr(10) & PCODE
-
-
Exit Function
-
-
AddressLabels_err:
-
AddressLabels = ""
-
Exit Function
-
-
End Function
??
MTB
QVeen72 1,445
Recognized Expert Top Contributor
Hi,
Change last part of your code: -
If IsNull(A6) Then
-
A6 = A7
-
A7 = Null
-
Else
-
A6 = A6
-
A7 = A7
-
End If
-
-
If IsNull(A7) Then
-
A7 = A8
-
A8 = Null
-
Else
-
A7 = A7
-
A8 = A8
-
End If
-
You are checking for Null, but Assigning a Blank String..
REgards
Veena
Cheers QVeen72, knew it would be something easy!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: JP SIngh |
last post by:
Hi All
I am trying to write a recursive function to list the managers and his
employees in a tree like sctructure
Manager 1
Emp1
Emp1.1
Emp 1.2
Emp 2
|
by: |
last post by:
Hello All, this is my first post.
OK - The goal is to display the following (note: substitute 1' ' for 2'*')
by using 3 recursive functions.
0123454321001234543210
**012343210012343210**...
|
by: |
last post by:
OK:
Purpose: Using user's input and 3 recursive functions, construct an hour
glass figure. Main can only have user input, loops and function calls.
Recursive function 1 takes input and displays...
|
by: Robert |
last post by:
Vb.Net Make dll that contain one function. Help Please.
I would like to call a function from different applications.
I think i have to make a dll.
I have Visual Basic.net 2003 Standard...
|
by: Goldie |
last post by:
Can some please look at this function and maybe help me with why it's
not doing as it's told... :)
It's basicall meant to check to see if that field returned from
database actually has any data...
| |
by: TC |
last post by:
IE only (V6).
First, I know very little JS and our resident expert is short on time,
so I come to you for help. I have a dynamic CGI script (written in
Progress) that generates the following...
|
by: Abersparky |
last post by:
Can someone help me with the mail() function???
The below is just to get myself going but I can't seem to get it
working... is there something else I should be doing? I checked
phpinfo() and the...
|
by: turtle |
last post by:
Background:
I have a table of fields each field representing a month (Jan, Feb,
Mar...). These are not a date field but more of a bucket to hold
labor actuals. Along with the months their is...
|
by: kang jia |
last post by:
hi
currently i am doing this search function for car booking website. it can search through either car seats or CarModel. it seems it able to do search function, however i small problem occurs to...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |