Advertisement

08.25.2008 at 08:52AM PDT, ID: 23675601
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Replace Function: Replacing from a table of values

Asked by biggans in SQL Query Syntax, Access Architecture/Design, Access Coding/Macros

Tags: , , ,

I have a problem using the replace function in MS Access 2003.  Basically, instead of hardcover the find and replacement variables, I want to make to find by a column in another table, and replace by another column.  

I need to replace a diacritic (é, ß, ö, etc) in a table, with an appropriate substitute in another table by country.  So in an address line, ö would be replaced by o if the record is from Denmark, but by oe if the address line is from Germany.

Is it possible to replace multiple diacritics in a field at the same time without hard coding the values in a query? See attached for a couple sample tables, values, and queries.

 The query seems to properly display replace a single diacritic but when an address field has several diacritics in the field, such as record 10 that row is displayed several times to remove each of the unique diacritics.

I know you can replace a field several times by doing: replace(replace([field], var1, replacevar1), var2, replacevar2)
example: Replace(Replace(Replace(Replace([address_1],'é','e'),'ü','u'),'ß','ss'),'ö','o')

But is there a way to replace the var1, var2 to instead check from a table?
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
CREATE table tblDiacritics
(
Country varchar(50),
Diacritic varchar(50),
DiacriticReplacment varchar(50)
)
 
CREATE table tblAddresses
(
Country varchar(50),
Address_1 varchar(50)
)
 
Note: The below values may not be the actual suggested replacement for diacritics per each country
INSERT INTO tblDiacritics
VALUES ('Germany', 'é', 'e')
INSERT INTO tblDiacritics
VALUES ('Germany', 'ü', ue')
INSERT INTO tblDiacritics
VALUES ('Germany', 'ö', 'oe')
INSERT INTO tblDiacritics
VALUES ('Denmark', 'ö', 'o')
 
INSERT INTO tblAddresses
VALUES ('10','Germany', 'Testéöüßé')
INSERT INTO tblAddresses
VALUES ('1','Germany', 'Testé')
INSERT INTO tblAddresses
VALUES ('2','Germany', 'Testö')
INSERT INTO tblAddresses
VALUES ('3','Denmark', 'Testö')
INSERT INTO tblAddresses
VALUES ('4','Test', 'Testéd')
INSERT INTO tblAddresses
VALUES ('5','Test', 'Tüstéd')
INSERT INTO tblAddresses
VALUES ('6','Germany', 'Tüstéd')
INSERT INTO tblAddresses
VALUES ('7','Germany', 'Test')
INSERT INTO tblAddresses
VALUES ('8','Germany', 'Teßed')
INSERT INTO tblAddresses
VALUES ('9','Germany', 'Tessed')
 
 
Here is my test query:
SELECT tblAddresses.RecordID, tblAddresses.Address_1, Replace(tblAddresses.Address_1,tblDiacritics.diacritic,tblDiacritics.DiacriticReplacment) AS Expr1, tblAddresses.Country
FROM tblAddresses INNER JOIN tblDiacritics ON tblAddresses.Country = tblDiacritics.Country
WHERE (((tblAddresses.Address_1) Like "*" & [tblDiacritics].[diacritic] & "*"));
[+][-]08.25.2008 at 09:05AM PDT, ID: 22306634

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.25.2008 at 09:10AM PDT, ID: 22306673

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.25.2008 at 10:15AM PDT, ID: 22307239

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.11.2008 at 12:07PM PDT, ID: 22453452

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Query Syntax, Access Architecture/Design, Access Coding/Macros
Tags: Microsoft, Access, 2003, Replace Function
Sign Up Now!
Solution Provided By: biggans
Participating Experts: 2
Solution Grade: A
 
 
[+][-]09.11.2008 at 12:10PM PDT, ID: 22453485

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-42 / EE_QW_2_20070628