Solved

remove comma in access query

Posted on 2014-02-19
3
1,952 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
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

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…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 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