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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generic address handling routine (removes blank lines) 1

Status
Not open for further replies.

WarrenTheWindmill

Programmer
Sep 8, 2000
18
GB
Want an easy way of setting up a multiple line address?

Use this formula (courtesy of Frobisher) :

Dim Address(6) As String
Local I
Local AddressOut As String

If Not IsNull({ADDRESSES.ADDR_LINE1}) Then
Address(1) = {ADDRESSES.ADDR_LINE1}
End If
If Not IsNull({ADDRESSES.ADDR_LINE2}) Then
Address(2) = {ADDRESSES.ADDR_LINE2}
End If
If Not IsNull({ADDRESSES.ADDR_LINE3}) Then
Address(3) = {ADDRESSES.ADDR_LINE3}
End If
If Not IsNull({ADDRESSES.ADDR_LINE4}) Then
Address(4) = {ADDRESSES.ADDR_LINE4}
End If
If Not IsNull({ADDRESSES.ADDR_LINE5}) Then
Address(5) = {ADDRESSES.ADDR_LINE5}
End If
If Not IsNull({ADDRESSES.POST_CODE}) Then
Address(6) = {ADDRESSES.POST_CODE}
End If


For I = 1 To 6
If Address(I) <> &quot;&quot; Then
AddressOut = AddressOut & Address(I) & Chr(13) & Chr(10)
End If
Next I

AddressOut = AddressOut & Chr(13) & Chr(10)


Formula = AddressOut

 
Hi,

Why do you need to do this ?

Crystal automatically does this when you add the fields
into a text box on separate lines. The format option
suppress blank lines does the trick.

What would be more useful would be an easy way of generating an address layout that would be able to be controlled using a parameter.

How do you convert all addresses from maximum of 9 detail fields to a maximum of 6 Lines, or 4 lines.

Eg. From
Name
Flat
Housename
House_no
Street
Village
Town
City
Postcode

To or
Name Name
Flat, Housename Flat, Housename, House_No Street
House_No Street Village, Town, City
Village, Town Postcode
City
Postcode

NB.
It must be able to cater for null/blank values and not leave unnecessary commas/blank spaces!


Any suggestions ??

Geoff
 
Geoff;

I am not fond of your suggestion, if I have it right...are you suggestion embedding the addess fields into a text box?

I have experienced severe performance poroblems related to this method.

I prefer the formula method outlined above with a &quot;can grow&quot; box checked....I ususlly place this field in a separate subsection so that it will not overwrite what comes below.

As far as your problem goes....this could be done in a formula with a Select case to decide which format you want controlled by an input parameter

stringVar Address;
Select {?address_type}

case 1:
( code for 9 line address)
case 2:
( code for 4 line address);

Address;

*****************************

I personally would not do the assembly of the address the way it was described by AngeloDim though since it seems like he/she is doing it twice...I would simply add address lines and apprpriate CR and Line feeds after I test for nulls.

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top