Solved

wrong case in the result of Replace Function

Posted on 2013-05-16
2
426 Views
Last Modified: 2013-05-17
I have a small function to screen for French-accented characters and replace them with unaccented English characters. It works OK for uppercase characters, but it replaces a lower-case French character with the upper-case English character.

The specified replacement character IS lower case, so it seems that VBA is making the case decision in spite of what is specified in my code.

I am attaching a small database, ReplaceProblem.accdb with one module in it that shows everything about the problem.

I am also attaching two screen shots of the erroneous results.
ReplaceProblem.accdb
CleanChar-problem.JPG
CleanChar-problem2.JPG
0
Comment
Question by:dmaclean2
2 Comments
 
LVL 17

Accepted Solution

by:
Chris Millard earned 500 total points
ID: 39173972
I've revised the function a little so that the REPLACE function uses vbBinaryCompare. Try this:-

Public Function CleanChar(inString As String) As String
On Error GoTo HandleError
Dim i As Long
Dim CleanTemp As String
    CleanTemp = inString
    For i = 1 To CleanCharMax
            CleanTemp = Replace(CleanTemp, inProbChar(i), outCleanChar(i), , , vbBinaryCompare)
    Next i
    CleanChar = CleanTemp
ExitProc:
    Exit Function
HandleError:
    MsgBox Err.Number & " " & Err.Description & " in CleanChar", vbOKOnly + vbCritical, ModName
    Resume ExitProc
End Function

Open in new window

0
 

Author Closing Comment

by:dmaclean2
ID: 39174061
Perfect solution. And I learned something important about Replace options.
Thanks much, roybridge!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

911 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

20 Experts available now in Live!

Get 1:1 Help Now