Solved

remove comma in access query

Posted on 2014-02-19
3
2,004 Views
Last Modified: 2014-02-20
I have an access query that exports out as a pipe delimited file.  I have no control how the databases are set up.

I have to have to have 2 fields, one last name, one first name.  Sometimes when the name has a JR or a III (or any other suffix) after the name - there is a comma between the JR or the III.  Sometimes the database entry is ok with no comma, some times not. I just depends on how it was entered in the database table.

Good:    |SMITH|EDWARD H III|

BAD:     |JONES|III, ROBERT D |  BAD

In the database this is an example of  how the name looks in the database  
The Good entry:   SMITH, EDWARD H III
The bad entry:     JONES, III, ROBERT D


I have an iff then statement to split up the Last name and first name.  What I need is to get rid of any commas that might be in PHM_CHARGES_ENHANCED.DR_NAME OR MAKE_PHM_CURES.DR_NAME


LAST NAME: IIf([PHM_CHARGES_ENHANCED.DR_NUMBER]="000000" Or IsNull([PHM_CHARGES_ENHANCED.DR_NUMBER]) Or [EC-CLN]<1,Left([MAKE_PHM_CURES.DR_NAME],[CU-CLN]),Left([PHM_CHARGES_ENHANCED.DR_NAME],[EC-CLN]))

FIRST NAME : IIf([PHM_CHARGES_ENHANCED]![DR_NUMBER]="000000" Or IsNull([PHM_CHARGES_ENHANCED]![DR_NUMBER]) Or [EC-CLN]<1,Mid([MAKE_PHM_CURES.DR_NAME],[CU-CFN]),Mid([PHM_CHARGES_ENHANCED.DR_NAME],[EC-CFN]))
0
Comment
Question by:joylene6
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 96

Assisted Solution

by:Lee W, MVP
Lee W, MVP earned 250 total points
ID: 39872397
Using the replace function should do the trick:

REPLACE(FIELD, ",", "")

Replaces all commas with "nothing" (basically removes them).

Please try it.
0
 
LVL 1

Author Comment

by:joylene6
ID: 39872411
Any idea where I should stick it?  the REPLACE(FIELD, ",", "")

LAST NAME: IIf([PHM_CHARGES_ENHANCED.DR_NUMBER]="000000" Or IsNull([PHM_CHARGES_ENHANCED.DR_NUMBER]) Or [EC-CLN]<1,Left([MAKE_PHM_CURES.DR_NAME],[CU-CLN]),Left([PHM_CHARGES_ENHANCED.DR_NAME],[EC-CLN]))
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 39872997
Try this:

LAST NAME: IIf([PHM_CHARGES_ENHANCED.DR_NUMBER]="000000" Or IsNull([PHM_CHARGES_ENHANCED.DR_NUMBER]) Or [EC-CLN]<1,Left([MAKE_PHM_CURES.DR_NAME],[CU-CLN]),Replace(Left(PHM_CHARGES_ENHANCED.DR_NAME],[EC-CLN]),",", ""))
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

Suggested Solutions

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

738 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