peskywinnets
Registered User.
- Local time
- Today, 20:00
- Joined
- Feb 4, 2014
- Messages
- 578
Concatenating address fields but skipping blank fields
Ok, I've tried (I really have) & googled (a lot), but I'm not quite getting it!.
I seek to Concatenate address fields in a query, skipping those fields that are blank.
At first I was using the mother of all nested iif(), but frankly it was getting unwieldly, I then established I should be making use of the + operator instead....
....it sort of works but my query output still has a blank lines embedded. For example if someone hasn't entered a ShippingAddress2 in their Shipping Address (or a ShippingRegion ...what some would refer to as State), I get this output...
Joe Brown
1 Acacia Terrace
London
N12 7YF
...so how do I change the above code so that the output would look like this (i.e. no empty/blank lines)...
Joe Brown
1 Acacia Terrace
London
N12 7YF
the main culprit shipping address fields that are quite often blank are ShippingAddress2 (shipping address line 2), ShippingRegion & ShippingPostcode (e.g. many parts of Ireland still don't have a postcode)
Ok, I've tried (I really have) & googled (a lot), but I'm not quite getting it!.
I seek to Concatenate address fields in a query, skipping those fields that are blank.
At first I was using the mother of all nested iif(), but frankly it was getting unwieldly, I then established I should be making use of the + operator instead....
Code:
ShippingAddress: [ShippingName]+Chr(13) & Chr(10)+[ShippingAddress1]+Chr(13) & Chr(10)+[ShippingAddress2]+Chr(13) & Chr(10)+[ShippingCity]+Chr(13) & Chr(10)+[ShippingRegion]+Chr(13) & Chr(10)+[ShippingPostcode]
....it sort of works but my query output still has a blank lines embedded. For example if someone hasn't entered a ShippingAddress2 in their Shipping Address (or a ShippingRegion ...what some would refer to as State), I get this output...
Joe Brown
1 Acacia Terrace
London
N12 7YF
...so how do I change the above code so that the output would look like this (i.e. no empty/blank lines)...
Joe Brown
1 Acacia Terrace
London
N12 7YF
the main culprit shipping address fields that are quite often blank are ShippingAddress2 (shipping address line 2), ShippingRegion & ShippingPostcode (e.g. many parts of Ireland still don't have a postcode)
Last edited: