Solved

How get rid of second comma in a concatenated field if there is no data in the 2nd field

Posted on 2014-03-15
2
303 Views
Last Modified: 2014-03-15
I have this syntaxin a query designer field but need to get rid of the 2nd comma if there is no data in the field "Address2)

Street Address: [Address1] & IIf([Address2]="","",", " & [Address2])

Right as it stands I get, for example,

1234 West Circle Drive,

but want to get just

1234 West Circle Drive  (no comma)


What is wrong with my syntax?

--Steve
0
Comment
Question by:SteveL13
2 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 39931629
Generally, the address2 would be NULL not "", if that is the case, you can simply use:

StreetAddress: [Address1] & (", " + [Address2])

The use of the + to concatenate the comma and [Address2] will result in a NULL value if [Address2] is NULL. If you use a '&' to do the concatenation, it would result in ','

If [Address2] could be NULL or an empty string, then I would recommend:

StreetAddress: = [Address1] & IIF([Address2] & "" = "", NULL, ", " & [Address2])
0
 

Author Comment

by:SteveL13
ID: 39931650
Perfect solution.  Thanks.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question