RecipeDan
asked on
Loop without Do Error
Hello:
I am trying to assign a team to review another team progress. However one team cannot have more than 1 team to review. When I run the script it gives a Loop without Do Error
I am trying to assign a team to review another team progress. However one team cannot have more than 1 team to review. When I run the script it gives a Loop without Do Error
strSQLAccess11 = "SELECT Distinct TeamName FROM Data WHERE Selected = 'No' Order by TeamName"
rsAccess11.Open strSQLAccess11, cnAccess11, strDBCursorType, strDBLockType, strDBOptions
If rsAccess11.EOF Then
MsgBox "All Done!"
Else
Do While Not rsAccess11.EOF
TeamName = rsAccess11("TeamName")
strSQLAccess12 = "SELECT Data.TeamName, AdjNameDept.Dept FROM Data INNER JOIN AdjNameDept ON Data.TeamName = AdjNameDept.Fullteamname WHERE TeamName <> '" & TeamName & "'"
rsAccess12.Open strSQLAccess12, cnAccess12, strDBCursorType, strDBLockType, strDBOptions
If rsAccess12.EOF Then
strSQLAccess13 = "UPDATE Data Set TeamReviewer = 'No Team Reviewer' WHERE TeamName = '" & TeamName & "'"
rsAccess13.Open strSQLAccess13, cnAccess13, strDBCursorType, strDBLockType, strDBOptions
Else
TeamReviewer = rsAccess12("TeamName")
strSQLAccess14 = "SELECT TeamReviewer FROM Data WHERE TeamReviewer = '" & TeamReviewer & "'"
rsAccess14.Open strSQLAccess14, cnAccess14, strDBCursorType, strDBLockType, strDBOptions
If Not rsAccess14.EOF Then
rsAccess11.MoveNext
Loop
Else
TeamReviewer = rsAccess14("TeamReviewer")
strSQLAccess15 = "UPDATE Data Set TeamReviewer = '" & TeamReviewer & "', Selected = 'Yes' WHERE TeamName = '" & TeamName & "'"
rsAccess15.Open strSQLAccess15, cnAccess15, strDBCursorType, strDBLockType, strDBOptions
rsAccess11.MoveNext
Loop
End If
End If
End If
ASKER
I tried removing them one at a time and still get the same error.
In line 21 if the TeamReviewer is already assigned a team I want the script to go to the next record (rsAccess11)
In line 27 after the TeamReviewer is assigned a team I want the script to go to the next record (rsAccess11)
Does this make sense?
In line 21 if the TeamReviewer is already assigned a team I want the script to go to the next record (rsAccess11)
In line 27 after the TeamReviewer is assigned a team I want the script to go to the next record (rsAccess11)
Does this make sense?
Well, either way ... one of the Loop statements has to go ... you can only have one per Do.
mx
mx
"I tried removing them one at a time and still get the same error. "
Besides the extra Loop ... you can still get that error if the
IF ELSE and END IF 's are not balanced.
mx
Besides the extra Loop ... you can still get that error if the
IF ELSE and END IF 's are not balanced.
mx
Besides having an extra loop, the end ifs for your if statement are outside the loop statement.
This is the reason it is giving the error.
This is the reason it is giving the error.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you. I figured out a similar solution to nmilmine
mx