Solved

remove comma in access query

Posted on 2014-02-19
3
1,801 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
3 Comments
 
LVL 95

Assisted Solution

by:Lee W, MVP
Lee W, MVP earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now