Hello,
I'm trying to bull this string from a field that is in between characters. Everything seems to work but except when it comes to the update query it appends 0 records when there is the right criteria there for it. Here is my code beloww:
Public Function ExtractString()
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim strAll As String
Dim strExtract As String
Dim strSQL As String
Dim strLength As Integer
Dim startPos As Integer
Dim lastPos As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM Copy_Producer_World_Final")
strAll = rs.Fields(3).Value
Do Until rs.EOF
startPos = InStr(strAll, "Primary Phone:")
If (startPos > 0) Then
lastPos = InStr(strAll, "Blank")
strLength = (lastPos - startPos)
strExtract = Mid(strAll, startPos, strLength)
strSQL = "UPDATE Table1 SET Table1.Phone = '" & strExtract & "';"
DoCmd.RunSQL (strSQL)
End If
rs.MoveNext
Loop
MsgBox "Done"
Set db = Nothing
Set rs = Nothing
End Function