Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
308 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 49

Accepted Solution

by:
Dale Fye earned 2000 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

824 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