Question : Update Query to Delete everything to thr right: 4th comma

Access 2003

I need an Update query that will delete everything to the left of the 4th comma in a a string.
=====================================
Or maybe I need a function like this Revised:

Function getword(mystring As String) As String
Dim v As Variant
v = Split(Left([mystring], InStr([mystring], ",") - 1), " ")
getword = v(UBound(v))
End Function

UPDATE tblRichText set fldFirstComma = getword(fldRichText)
==========================================

Sometimes the field may not have 4 commas, or  No commas at all.

Thanks
fordraiders


Answer : Update Query to Delete everything to thr right: 4th comma

try this

Function getWord(s As String) As String
Dim xArr, j, sTemp
xArr = Split(s, ",")
If UBound(xArr) < 4 Then
    'comma is less then 4
    getWord = s
    Else
    xArr = Split(s, ",", 5)
    For j = 0 To UBound(xArr) - 1
        sTemp = sTemp & xArr(j) & ","
    Next
    getWord = Left(sTemp, Len(sTemp) - 1)
End If
End Function
Random Solutions  
 
programming4us programming4us