I inherited a program and the code below I am running into some issues. It uses 3 tables, TblScrapedCruiseLineData, TblCruiseCorrectionList and Dargal_ScrapedData.
Basically, data is scraped and placed in Darga_ScrapedData. The code parses the data from it to the TblScrapedCruiseLineData, but will look at the TblCruiseCorrectionList for and updates/corrections. When I quote out the second line: On Error Resume Next, I find errors on line *** (I marked it below).
When I quote out line: On Error Resume Next it will stop on record 226 with the Runtime Error 5. When that line is not quoted out, it will stop on record 1889, no error message, it just quits responding and sits there and I have to close and reopen the app. There 4063 records in the Dargal_ScrapedData.
I have no idea what to do. Thanks in advance!


Public Function ParseCruiseData()
On Error Resume Next
Dim rs1 As Recordset
Dim str1 As String
Dim str2 As String
Dim i As Integer
Dim tmpstr As String
Dim tmpArr() As String
Dim recCount As Integer
Dim k As Integer
Dim rs2 As Recordset
Dim pos1 As Integer
Dim pos2 As Integer
Dim tmpport As String
Dim tmpcruiseline As String
Dim tmpregion As String
Dim tmpship As String
Dim tmpitin As String
Dim pos3 As Integer
Dim pos4 As Integer
Dim tmpprice As String
Dim isdone As Integer
Dim tmpArr2() As String

DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from TblScrapedCruiseLineData"

Set rs1 = CurrentDb.OpenRecordset("Dargal_ScrapedData", dbOpenDynaset, dbSeeChanges)

rs1.MoveFirst
rs1.MoveLast
recCount = rs1.RecordCount

rs1.MoveFirst

For i = 0 To recCount - 1
tmpArr = Split(rs1!Cruiselinedata, vbCrLf)
tmpstr = ""
For k = 0 To UBound(tmpArr)
str1 = Trim(tmpArr(k))
If Len(str1) > 0 Then tmpstr = tmpstr & str1 & vbCrLf
Next k
rs1.Edit
rs1!Cruiselinedata = tmpstr
rs1.Update
rs1.MoveNext
Next

k = 0
rs1.MoveFirst

Set rs2 = CurrentDb.OpenRecordset("TblScrapedCruiseLineData" , dbOpenDynaset, dbSeeChanges)
For i = 0 To recCount - 1
pos1 = 0
pos2 = 0
tmpArr = Split(rs1!Cruiselinedata, vbCrLf)
pos1 = InStr(1, rs1!CruiseLineAnchor, "cruises/")
pos2 = InStr(pos1 + 9, rs1!CruiseLineAnchor, "/")
pos2 = pos2 - 1

rs2.AddNew
If tmpArr(4) = "View Details BOOK NOW" Then
tmpcruiseline = ""
tmpcruiseline = Nz(DLookup("NewValue", "TblCruiseCorrectionList", "Category='CruiseLine' and Oldvalue='" & Mid(rs1!CruiseLineAnchor, pos1 + 8, pos2 - pos1 - 7) & "'"))

If tmpcruiseline <> "" Then
rs2!CruiseLine = Trim(tmpcruiseline)
Else
rs2!CruiseLine = Mid(rs1!CruiseLineAnchor, pos1 + 8, pos2 - pos1 - 7)
End If


pos1 = InStr(1, Trim(tmpArr(0)), "night")
pos2 = InStr(1, Trim(tmpArr(0)), "from")
If pos2 = 0 Then

tmpregion = ""
tmpregion = DLookup("NewValue", "TblCruiseCorrectionList", "Category='Region' and Oldvalue='" & Trim(Mid(Trim(tmpArr(0)), pos1 + 5)) & "'")
If tmpship <> "" Then
rs2!Region = Trim(tmpregion)
Else
rs2!Region = Trim(Mid(Trim(tmpArr(0)), pos1 + 5))
End If
Else

tmpregion = ""
tmpregion = Nz(DLookup("NewValue", "TblCruiseCorrectionList", "Category='Region' and Oldvalue='" & Trim(Mid(Trim(tmpArr(0)), pos1 + 5, pos2 - pos1 - 5)) & "'"))
If tmpregion <> "" Then
rs2!Region = Trim(tmpregion)
Else
rs2!Region = Trim(Mid(Trim(tmpArr(0)), pos1 + 5, pos2 - pos1 - 5))
End If
End If


tmpship = ""
tmpship = Nz(DLookup("NewValue", "TblCruiseCorrectionList", "Category='Ship' and Oldvalue='" & Trim(tmpArr(3)) & "'"))
If tmpship <> "" Then
rs2!shipcode = Trim(tmpship)
Else
rs2!shipcode = Trim(tmpArr(3))
End If

rs2!saildate = Trim(tmpArr(6))
rs2!Nights = Mid(tmpArr(0), 1, InStr(1, tmpArr(0), "-") - 1)

If tmpArr(4) = "View Details BOOK NOW" Then

tmpprice = tmpArr(14)
tmpprice = Replace(tmpprice, "Call for rates", "Callforrates")
tmpArr2 = Split(tmpprice, " ")
rs2!Inside = tmpArr2(0)
rs2!outside = tmpArr2(1)
rs2!balcony = tmpArr2(2)

rs2!Inside = Replace(tmpArr(14), "Call for rates", "Callforrates")
rs2!outside = Replace(tmpArr(15), "Call for rates", "Callforrates")
rs2!balcony = Replace(tmpArr(13), "Call for rates", "Callforrates")

Else

tmpprice = tmpArr(13)
tmpprice = Replace(tmpprice, "Call for rates", "Callforrates")
tmpArr2 = Split(tmpprice, " ")
rs2!Inside = tmpArr2(0)
rs2!outside = tmpArr2(1)
rs2!balcony = tmpArr2(2)

rs2!Inside = Replace(tmpArr2(13), "Call for rates", "Callforrates")
rs2!outside = Replace(tmpArr2(14), "Call for rates", "Callforrates")
rs2!balcony = Replace(tmpArr2(15), "Call for rates", "Callforrates")
End If

isdone = 0
tmpitin = ""
tmpitin = tmpArr(8)

Do While isdone = 0
If InStr(tmpitin, "(") > 0 Then
pos3 = 0
pos4 = 0
pos3 = InStr(tmpitin, "(")
pos4 = InStr(pos3, tmpitin, ")")
tmpitin = Left(tmpitin, pos3 - 1) + " " + Mid(tmpitin, pos4 + 1)
Else
isdone = 1
End If
Loop

tmpitin = RemoveDays(tmpitin)

rs2!Itinerary = Trim(tmpitin)

tmpport = ""
tmpport = Nz(DLookup("NewValue", "TblCruiseCorrectionList", "Category='Port' and Oldvalue='" & Mid(tmpArr(8), 1, InStr(1, tmpArr(8), ", ") - 1) & "'"))

If tmpport = "" Then
tmpport = Trim(Mid(tmpArr(8), 1, InStr(1, tmpArr(8), ",") - 1))
End If
isdone = 0
Do While isdone = 0
If InStr(tmpport, "(") > 0 Then
pos3 = 0
pos4 = 0
pos3 = InStr(tmpport, "(")
pos4 = InStr(pos3, tmpport, ")")
tmpport = Left(tmpport, pos3 - 1) + " " + Mid(tmpport, pos4 + 1)
Else
isdone = 1
End If
Loop

tmpport = RemoveDays(tmpport)
rs2!PortCode = Trim(tmpport)
Else

tmpcruiseline = ""
tmpcruiseline = Nz(DLookup("NewValue", "TblCruiseCorrectionList", "Category='CruiseLine' and Oldvalue='" & Mid(rs1!CruiseLineAnchor, pos1 + 8, pos2 - pos1 - 7) & "'"))
If tmpcruiseline <> "" Then
rs2!CruiseLine = Trim(tmpcruiseline)
Else
rs2!CruiseLine = Mid(rs1!CruiseLineAnchor, pos1 + 8, pos2 - pos1 - 7)
End If

pos1 = InStr(1, Trim(tmpArr(0)), "night")
pos2 = InStr(1, Trim(tmpArr(0)), "from")
If pos2 = 0 Then

tmpregion = ""
tmpregion = Nz(DLookup("NewValue", "TblCruiseCorrectionList", "Category='Region' and Oldvalue='" & Trim(Mid(Trim(tmpArr(0)), pos1 + 5)) & "'"))

If tmpregion <> "" Then
rs2!Region = Trim(tmpregion)
Else
rs2!Region = Trim(Mid(Trim(tmpArr(0)), pos1 + 5))
End If
Else

tmpregion = ""
tmpregion = DLookup("NewValue", "TblCruiseCorrectionList", "Category='Region' and Oldvalue='" & Trim(Mid(Trim(tmpArr(0)), pos1 + 5, pos2 - pos1 - 5)) & "'")
If tmpregion <> "" Then
rs2!Region = Trim(tmpregion)
Else
rs2!Region = Trim(Mid(Trim(tmpArr(0)), pos1 + 5, pos2 - pos1 - 5))
End If
End If

tmpship = ""
tmpship = Nz(DLookup("NewValue", "TblCruiseCorrectionList", "Category='Ship' and Oldvalue='" & Trim(tmpArr(3)) & "'"))

If tmpship <> "" Then
rs2!shipcode = Trim(tmpship)
Else
rs2!shipcode = Trim(tmpArr(3))
End If


rs2!saildate = Trim(tmpArr(5))
rs2!Nights = Mid(tmpArr(0), 1, InStr(1, tmpArr(0), "-") - 1)


isdone = 0
tmpitin = ""
tmpitin = tmpArr(7)

Do While isdone = 0
If InStr(tmpitin, "(") > 0 Then
'tmpitin = Left(tmpitin, InStr(tmpitin, "(") - 1)
pos3 = 0
pos4 = 0
pos3 = InStr(tmpitin, "(")
pos4 = InStr(pos3, tmpitin, ")")
tmpitin = Left(tmpitin, pos3 - 1) + " " + Mid(tmpitin, pos4 + 1)

Else
isdone = 1
End If

Loop
'rs2!itinerary = tmpArr(7)
tmpitin = RemoveDays(tmpitin)
rs2!Itinerary = tmpitin

tmpport = ""
*** tmpport = Nz(DLookup("NewValue", "TblCruiseCorrectionList", "Category='Port' and Oldvalue='" & Mid(tmpArr(7), 1, InStr(1, tmpArr(7), ",") - 1) & "'"))
If tmpport = "" Then
tmpport = Trim(Mid(tmpArr(7), 1, InStr(1, tmpArr(7), ",") - 1))
End If
isdone = 0
Do While isdone = 0
If InStr(tmpport, "(") > 0 Then
'tmpport = Left(tmpport, InStr(tmpport, "(") - 1)

pos3 = 0
pos4 = 0
pos3 = InStr(tmpport, "(")
pos4 = InStr(pos3, tmpport, ")")
tmpport = Left(tmpport, pos3 - 1) + " " + Mid(tmpport, pos4 + 1)
Else
isdone = 1
End If
Loop

tmpport = RemoveDays(tmpport)
rs2!PortCode = Trim(tmpport)


End If

rs2.Update

rs1.MoveNext
Next

rs1.Close
Set rs1 = Nothing
rs2.Close
Set rs2 = Nothing

DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from TblScrapedCruiseLineData where trim([Inside])='Callforrates' and trim([Outside])='Callforrates' and trim([balcony])='Callforrates'"
DoCmd.RunSQL "UPDATE TblScrapedCruiseLineData SET TblScrapedCruiseLineData.Inside = '' WHERE TblScrapedCruiseLineData.Inside = 'Callforrates'"
DoCmd.RunSQL "UPDATE TblScrapedCruiseLineData SET TblScrapedCruiseLineData.Outside = '' WHERE TblScrapedCruiseLineData.Outside = 'Callforrates'"
DoCmd.RunSQL "UPDATE TblScrapedCruiseLineData SET TblScrapedCruiseLineData.balcony = '' WHERE TblScrapedCruiseLineData.balcony = 'Callforrates'"


End Function