Split Form Key words (1 Viewer)

dascott

New member
Local time
Today, 02:38
Joined
Jun 24, 2010
Messages
2
Hello,

I am currently swithing over from a 3rd party library data base to MS Access 2007, one of the requirements was to add a new "search terms" field. What I have been doing is just taking the title such as "Generic Process Involved to Accomplish Laa dee daa in Utah" and shortening it to "Generic Process, Laa dee daa, Utah". The problem is that there are 13,000+ entries and I'm copy pasting & editing one field at a time. I was wondering if there was a way to automate this by copying the text from [Title] and moving it to [Search terms] while removing unnessesary words like "and" "or" "the" etc. If anyone can help that would be wonderful.
 

ajetrumpet

Banned
Local time
Today, 03:38
Joined
Jun 22, 2007
Messages
5,638
try this function on the table:
Code:
Function t()

Dim searchstr As String
Dim compstr As String
Dim var() As String
Dim i As Integer

searchstr = "WORD1,WORD2,ETC..."  [COLOR="Green"]'ex - "in,the,and,or"[/COLOR]

Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("YOUR TABLE NAME")

rs.MoveLast
rs.MoveFirst

Do Until rs.EOF

    var = Split(rs.Fields("TITLE FIELD"), " ")

        For i = LBound(var) To UBound(var)
            If InStr(searchstr, var(i)) = 0 Then
                compstr = compstr & var(i) & " "
            End If
        Next i
        
            compstr = Left(compstr, Len(compstr) - 1)
                 rs.edit
                 rs.fields("SEARCH TERMS") = compstr
                 rs.update
            compstr = ""
                 rs.MoveNext
            
Loop

rs.Close
Set rs = Nothing

End Function
 

dascott

New member
Local time
Today, 02:38
Joined
Jun 24, 2010
Messages
2
Thank you a ton! That worked beautifully.
 

Users who are viewing this thread

Top Bottom