Marko -
A paramArray works pretty well in a situation where you have a number
of items to check for. It might be a tad slow for a large number of
records, but since this appears to be a one-time shot, it well may be
worth the wait.
******************** the code ********************
Public Function ReplHue(pStr As String, ParamArray varMyVals() As
Variant) As String
'*******************************************
'Re:
http://groups.google.com/group/comp.databases.ms-access/browse_
frm/thread/077757357b36d7da/44153ba1796871c6?hl=en#44153ba1796871c6
'Purpose: Replace specified portion of
' string with another designation.
'Coded by: raskew
'Inputs: from debug (immediate) window
' ? replHue("Green/White/Red/Black", "Yellow", "Yel",
"Black", "Blk", "White", "Wht")
'Output: Green/Wht/Red/Blk
'*******************************************
Dim i As Integer
Dim n As Integer
Dim strHold As String
strHold = pStr
For i = 0 To UBound(varMyVals) Step 2
n = InStr(strHold, varMyVals(i))
If n > 0 Then
strHold = Left(strHold, n - 1) & varMyVals(i + 1) &
Mid(strHold, n + Len(varMyVals(i)))
End If
Next i
ReplHue = strHold
End Function
******************** end code ********************
You can test it as shown in the comments. Once satisfied with its
operation,
with the options modified to meet your needs, create a test query with
a calculated field showing the results after applying ReplHue, e.g.
**********query starts**********
SELECT
tblColor2.ID
, tblColor2.Color
, replHue([color],"Yellow","Yel","Black","Blk","White","Wht") AS
Fixed
FROM
tblColor2;
**********query ends************
(replace table and field names as necessary)
Finally, after backing-up your table!!!, create an update query using
the logic shown above.
HTH - Bob