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
304 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Flowing down data to other tables 13 35
how to insert parameter value in table 2 23
Run Access2013-32bit under WinXP? 4 37
Access 2016 - combo box 3 19
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

830 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