Hi to whom can help me

I seem to get this error:

Microsoft VBScript compilation error '800a040e'

'loop' without 'do'

/wspintranet/InformationTechnology/IT_Help_Desk_New/HelpDesk_AssetManagement/AssetManagement_Functions/Asset_Functions.asp, line 5155

Loop
^


Here is my code:

function ListSoftwareLicenses()

Dim strBody
Dim i

Set objBranchDC = Server.CreateObject("ADODB.Connection")
objBranchDC.Open Application("StaffDetails_ConnectionString")
Set objBranchRS = objBranchDC.Execute("SELECT Branches.BranchID, Branches.StrCity FROM Branches WHERE (((Branches.StrCity) Is Not Null)) ORDER BY Branches.StrCity;")
do until objBranchRS.eof
strCity=objBranchRS("StrCity")
intBranchID=objBranchRS("BranchID")

strBody = strBody & "<tr>"
strBody = strBody & "<td class=""header_background"" colspan=""9"">Branch : "
strBody = strBody & objBranchRS("StrCity")&"</td></tr>"

i=2

Set objDivisionDC = Server.CreateObject("ADODB.Connection")
objDivisionDC.Open Application("StaffDetails_ConnectionString")
Set objDivisionRS = objDivisionDC.Execute("SELECT BranchAddresses.OfficeName, BranchAddresses.StrCity FROM BranchAddresses WHERE (((BranchAddresses.StrCity)=" & intBranchID & ")) ORDER BY BranchAddresses.OfficeName;")

do until objDivisionRS.eof
strOfficeName=GetOfficeName(objDivisionRS("OfficeName"))

strBody = strBody & "<tr><td class=""headline"" colspan=""9"">Company : " & strOfficeName &"<br>"

Set objSoftwareDC = Server.CreateObject("ADODB.Connection")
objSoftwareDC.Open Application("SoftwarePackages_ConnectionString")
Set objSoftwareRS = objSoftwareDC.Execute("SELECT SoftwarePackages.SoftwareType, SoftwareVersions.Version, Count(SoftwareInstalled.MySoftwareID) AS CountOfSoftwareID FROM (SoftwarePackages RIGHT JOIN SoftwareInstalled ON SoftwarePackages.SoftwareID = SoftwareInstalled.SoftwareTypes) LEFT JOIN SoftwareVersions ON SoftwareInstalled.Versions = SoftwareVersions.VersionID GROUP BY SoftwarePackages.SoftwareType, SoftwareVersions.Version ;")

do until objSoftwareRS.eof
strSoftwareType=objSoftwareRS("SoftwareType")

strBody = strBody & "<tr><td class=""headline"" colspan=""9"">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Software Package : " & strSoftwareType &"<br>"

objSoftwareRS.movenext
loop

Set CountSerialNumbersDC= Server.CreateObject("ADODB.Connection")
CountSerialNumbersDC.Open Application("SoftwarePackages_ConnectionString")
Set CountSerialNumbersRS= CountSerialNumbersDC.Execute("SELECT Count(Purchasing.ID) AS CountOfID FROM Purchasing WHERE (((Purchasing.Company)=" & objDivisionRS("OfficeName") & ") AND ((Purchasing.Branch)=" & intBranchID & "));")

strBody = strBody & "<tr><td class=""KnowledgeTable"" colspan=""9""> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; No. of Licenses Purchased by Company : " & CountSerialNumbersRS("CountOfID") &" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; No. of Licenses Purchased by Group : <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Total Number of Licenses Installed for Company : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Total Number of Licenses Installed for Group : </td></tr>"



strBody=strBody & "<tr class=""tableHead""><td>Staff Member</td><td>Version</td><td>Date Installed</td></tr>"

if CountSerialNumbersRS("CountOfID")= 0 then
strBody=strBody & "<tr><td class=""text"" colspan=""9"" align=""center""><br>No Software Packages have been allocated for this Division/Branch</td></tr>"
strBody=strBody & "<tr><td class=""text"" colspan=""9"" align=""center"">&nbsp;</td></tr>"

else

Set SerialNumbersDC= Server.CreateObject("ADODB.Connection")
SerialNumbersDC.Open Application("SoftwarePackages_ConnectionString")
Set SerialNumbersRS= SerialNumbersDC.Execute("SELECT SoftwarePackages.SoftwareType FROM SoftwarePackages ;")

Do until SerialNumbersRS.eof
strSoftwareType=SerialNumbersRS("SoftwareType")

Set SerialNumbersDC= Server.CreateObject("ADODB.Connection")
SerialNumbersDC.Open Application("SoftwarePackages_ConnectionString")
Set SerialNumbersRS= SerialNumbersDC.Execute("SELECT SoftwareVersions.Version FROM SoftwareVersions WHERE (((SoftwareVersions.VersionID)=" & intSoftwareID & ")) ;")

if not SerialNumbersRS.eof then
i=2
do while not SerialNumbersRS.eof
strBody = strBody & "<tr class=""" & SetRowStyleGray(i) & """>"
strBody = strBody & "<td class=""text"" valign=""top"">" & SerialNumbersRS("PostedByUserID") & "</td>"
strBody = strBody & "<td class=""text"" valign=""top"">" & SerialNumbersRS("Version") & "</td>"
strBody = strBody & "<td class=""text"" valign=""top"">" & SerialNumbersRS("DateOrder") & "</td>"

i=i+1


SerialNumbersRS.movenext
Loop

SerialNumbersRS.movenext
Loop


wend
strBody = strBody & "<tr><td colspan=""9""><hr></td></tr>"
end if
end if


objDivisionRS.movenext
loop

objBranchRS.movenext
loop



objBranchRS.Close
Set objBranchRS = Nothing
objBranchDC.Close
Set objBranchDC = Nothing


ListSoftwareLicenses= strBody
end function


i have put the line where the error is in bold.

i would appreciate anyone who knows about my error.