Keep getting a compile error "Loop without Do and cannot find where the issue is. Appears everything matches up!
Dim blnError As Boolean
Dim strErrMessage As String
'On Error GoTo ErrHandler
Set db = CurrentDb
Set rstSource = db.OpenRecordset("SELECT * FROM [Parsed Messages] WHERE [Exported] = False ORDER BY [Message Date], [Message DTG]")
Do Until rstSource.EOF
blnError = False
Set rstTarget = db.OpenRecordset("SELECT * FROM [CVS CSA Inventory] WHERE [CVS CSA] = '" & rstSource![CSA Number] & "' AND [EIS TSR Type] = 'START'")
'SAMs will have the CSA when it is created/assigned
If Not IsNull(rstSource![CSA]) Then
If Left(rstSource![CSA], 2) = "EU" Then
rstTarget![EIS CSA] = rstSource![CSA]
End If
If Not rstTarget.EOF Then
rstTarget.Edit
'TSR
If rstSource![Message Type] = "TSR" Then
If rstSource![Message Date] <> #12:00:00 AM# Then
If IsNull(rstTarget![EIS TSR Date]) Or (rstSource![Message Date] > rstTarget![EIS TSR Date]) Or (rstSource![Message Date] = rstTarget![EIS TSR Date] And rstSource![Message DTG] > rstTarget![EIS TSR DTG]) Then
If rstTarget![EIS Status] < 4 Then rstTarget![EIS Status] = 4
If Not IsNull(rstSource![Message Date]) Then rstTarget![EIS TSR Date] = rstSource![Message Date]
If Not IsNull(rstSource![Message DTG]) Then rstTarget![EIS TSR DTG] = rstSource![Message DTG]
If Not IsNull(rstSource![Message Number]) Then rstTarget![EIS TSR Number] = rstSource![Message Number]
End If
End If
End If
'SAM
If rstSource![Message Type] = "SAM" Then
If rstSource![Message Date] <> #12:00:00 AM# Then
If rstTarget![EIS Status] < 6 Then
If rstTarget![EIS Status] < 5 Then rstTarget![EIS Status] = 5
End If
If Not IsNull(rstSource![SAM Award Date]) Then
If IsNull(rstTarget![EIS SAM Award Date]) Or rstSource![SAM Award Date] > rstTarget![EIS SAM Award Date] Then
If rstTarget![EIS Status] < 6 Then rstTarget![EIS Status] = 6
rstTarget![EIS SAM Award Date] = rstSource![SAM Award Date]
End If
End If
If Not IsNull(rstSource![SAM Completion Date]) Then
If IsNull(rstTarget![EIS SAM Completion Date]) Or rstSource![SAM Completion Date] > rstTarget![EIS SAM Completion Date] Then
If rstTarget![EIS Status] < 7 Then rstTarget![EIS Status] = 7
rstTarget![EIS SAM Completion Date] = rstSource![SAM Completion Date]
End If
End If
End If
End If
rstTarget.Update
rstSource.Edit
rstSource![Exported] = True
rstSource.Update
End If
rstSource.MoveNext
Loop (Compile Error here!)
rstSource.Close
db.Close
Set rstTarget = Nothing
Set rstSource = Nothing
Set db = Nothing
Exit Sub
ErrHandler:
MsgBox "Error: " & Err.Description, vbOKOnly, "Processing Error"
If Not rstSource.EOF Then rstSource.MoveNext
blnError = True
Resume Next
End Sub
Dim blnError As Boolean
Dim strErrMessage As String
'On Error GoTo ErrHandler
Set db = CurrentDb
Set rstSource = db.OpenRecordset("SELECT * FROM [Parsed Messages] WHERE [Exported] = False ORDER BY [Message Date], [Message DTG]")
Do Until rstSource.EOF
blnError = False
Set rstTarget = db.OpenRecordset("SELECT * FROM [CVS CSA Inventory] WHERE [CVS CSA] = '" & rstSource![CSA Number] & "' AND [EIS TSR Type] = 'START'")
'SAMs will have the CSA when it is created/assigned
If Not IsNull(rstSource![CSA]) Then
If Left(rstSource![CSA], 2) = "EU" Then
rstTarget![EIS CSA] = rstSource![CSA]
End If
If Not rstTarget.EOF Then
rstTarget.Edit
'TSR
If rstSource![Message Type] = "TSR" Then
If rstSource![Message Date] <> #12:00:00 AM# Then
If IsNull(rstTarget![EIS TSR Date]) Or (rstSource![Message Date] > rstTarget![EIS TSR Date]) Or (rstSource![Message Date] = rstTarget![EIS TSR Date] And rstSource![Message DTG] > rstTarget![EIS TSR DTG]) Then
If rstTarget![EIS Status] < 4 Then rstTarget![EIS Status] = 4
If Not IsNull(rstSource![Message Date]) Then rstTarget![EIS TSR Date] = rstSource![Message Date]
If Not IsNull(rstSource![Message DTG]) Then rstTarget![EIS TSR DTG] = rstSource![Message DTG]
If Not IsNull(rstSource![Message Number]) Then rstTarget![EIS TSR Number] = rstSource![Message Number]
End If
End If
End If
'SAM
If rstSource![Message Type] = "SAM" Then
If rstSource![Message Date] <> #12:00:00 AM# Then
If rstTarget![EIS Status] < 6 Then
If rstTarget![EIS Status] < 5 Then rstTarget![EIS Status] = 5
End If
If Not IsNull(rstSource![SAM Award Date]) Then
If IsNull(rstTarget![EIS SAM Award Date]) Or rstSource![SAM Award Date] > rstTarget![EIS SAM Award Date] Then
If rstTarget![EIS Status] < 6 Then rstTarget![EIS Status] = 6
rstTarget![EIS SAM Award Date] = rstSource![SAM Award Date]
End If
End If
If Not IsNull(rstSource![SAM Completion Date]) Then
If IsNull(rstTarget![EIS SAM Completion Date]) Or rstSource![SAM Completion Date] > rstTarget![EIS SAM Completion Date] Then
If rstTarget![EIS Status] < 7 Then rstTarget![EIS Status] = 7
rstTarget![EIS SAM Completion Date] = rstSource![SAM Completion Date]
End If
End If
End If
End If
rstTarget.Update
rstSource.Edit
rstSource![Exported] = True
rstSource.Update
End If
rstSource.MoveNext
Loop (Compile Error here!)
rstSource.Close
db.Close
Set rstTarget = Nothing
Set rstSource = Nothing
Set db = Nothing
Exit Sub
ErrHandler:
MsgBox "Error: " & Err.Description, vbOKOnly, "Processing Error"
If Not rstSource.EOF Then rstSource.MoveNext
blnError = True
Resume Next
End Sub