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

x
?
Solved

remove comma in access query

Posted on 2014-02-19
3
Medium Priority
?
2,198 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 96

Assisted Solution

by:Lee W, MVP
Lee W, MVP earned 1000 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 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 1000 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

885 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