catsoncars
New member
- Local time
- Today, 06:24
- Joined
- Feb 2, 2010
- Messages
- 6
In an access database, data is imported daily from an external system. One of the fields in question is a text field and contains information that I would like to parse out to specific fields. I have picklists for each of these specific fields. Using VBA how would you match the list to a substring of the text? For example, BR is the list and has over 130 different combinations of letters and numbers. Let's say 78GH is one of the values. I want to match 78GH to the contents of the text field. If 78GH existed then I want to populate a separate field with 78GH. I have this working with recordset but it only works with short lists because of the string limitation in SQL.
But my list of 130 blows the code.
PHP:
Set rst = db.OpenRecordset("Select [CodeDrop] from CodeDrops WHERE [DataMineCD] = -1")
If rst.EOF = False And rst.BOF = False Then
rst.MoveFirst
Do While rst.EOF = False
strCriteria = strCriteria & " IIf(InStr(1,[Short Description], '" & rst!CodeDrop & "'" & ")>0,'" & rst!CodeDrop & "',"
strCriteria2 = strCriteria2 & " IIf(InStr(1,[Short Description], '" & rst!CodeDrop & "'" & ")>0,'" & rst!CodeDrop & "',"
parens = parens & ")"
rst.MoveNext
Loop
End If
strCriteria = Left(strCriteria, Len(strCriteria) - 1) & parens & " AS LoadVal"
strCriteria2 = Left(strCriteria2, Len(strCriteria2) - 1) & parens
'
Set qdf = Nothing
Set qdf = db.QueryDefs("qryExtractBRCDTL")
strSQL = "INSERT INTO MinedValuesCD ( [Ticket Number], [Short Description], LoadVal ) " & _
"SELECT TicketDetails.[Ticket Number], Remedy.[Short Description], " & _
strCriteria & _
" FROM TicketDetails INNER JOIN Remedy ON TicketDetails.[Ticket #] = Remedy.[Trouble Ticket #] " & _
" WHERE " & _
strCriteria2 & _
" AND TicketDetails.[Code Drop] Is Null AND OldTicket = 0; "
qdf.SQL = strSQL
DoCmd.OpenQuery "qryExtractBRCDTL"
But my list of 130 blows the code.