Aqui fiz as alterações que me pediu, e contua dando o mesmo erro Tipo de erro: Erro de compilação do Microsoft VBScript (0x800A03FB) 'Loop' esperado /teste_query.asp, line 181 Else A linha 181 é Else Vou te passa todo codigo HÁ AMIGO ESTOU MUITO GRATO PELA AJUDA QUE ESTA ME DANDO, segue o código <% option explicit %> <!--#Include file="conexao2.inc"--> <% Dim Conexaodb , rsCRJJ04 , Setor , strSQL , rsRamal , rsCRJJ042 , strSQL2 , rsCRJJ0421 , Ramal , CRJJ04 Setor=(request.QueryString("Grupo1")) Dim rsCRJJ0422 , strSQL3 , rsCRJJ0423 , strSQL4 , rsCRJJ0424 , strSQL5 , rsCRJJ0425 , strSQL6 , rsCRJJ0426 , strSQL7 Dim rsCRJJ0427 , strSQL8 , rsCRJJ0428 , strSQL9 Dim rsCRJJ049 , strSQL10 , totalEF call abreConexao strSQL = " Select grupo , as local " strSQL = strSQl & " From ramal " strSQL = strSQL & " where grupo like '%" & Setor & "%' " 'Set rsCRJJ042= conexaodb.Execute(strSQL) strSQL2 = " Select Origem , COUNT ( * ) AS totalEf " strSQL2 = strSQL2 & " From Ramal , CRJJ04 " strSQL2 = strSql2 & " WHERE Ramal.Ramal=CRJJ04.Origem " strSQL2 = strSQL2 & " And grupo Like '%" & Setor & "%' And servico = 1 " strSQL2 = strSQL2 & " GROUP BY Origem " strSQL2 = strSQL2 & " ORDER BY 1 Asc " Set rsCRJJ0421 = conexaodb.Execute(strSQL2) strSQL3 = " Select Origem , COUNT ( * ) AS totalEf1 " strSQL3 = strSQL3 & " From Ramal , CRJJ04 " strSQL3 = strSql3 & " WHERE Ramal.Ramal=CRJJ04.Origem " strSQL3 = strSQL3 & " And grupo Like '%" & Setor & "%' And servico = 2 " strSQL3 = strSQL3 & " GROUP BY Origem " strSQL3 = strSQL3 & " ORDER BY 1 Asc " Set rsCRJJ0422 = conexaodb.Execute(strSQL3) strSQL4 = " Select Origem , COUNT ( * ) AS totalEf2 " strSQL4 = strSQL4 & " From Ramal , CRJJ04 " strSQL4 = strSql4 & " WHERE Ramal.Ramal=CRJJ04.Origem " strSQL4 = strSQL4 & " And grupo Like '%" & Setor & "%' And servico = 3 And 4 " strSQL4 = strSQL4 & " GROUP BY Origem " strSQL4 = strSQL4 & " ORDER BY 1 Asc " Set rsCRJJ0423 = conexaodb.Execute(strSQL4) strSQL5 = " Select Origem , COUNT ( * ) AS totalEf3 " strSQL5 = strSQL5 & " From Ramal , CRJJ04 " strSQL5 = strSql5 & " WHERE Ramal.Ramal=CRJJ04.Origem " strSQL5 = strSQL5 & " And grupo Like '%" & Setor & "%' And servico = 5 And 6 And 7 " strSQL5 = strSQL5 & " GROUP BY Origem " strSQL5 = strSQL5 & " ORDER BY 1 Asc " Set rsCRJJ0424 = conexaodb.Execute(strSQL5) strSQL6 = " Select Origem , COUNT ( * ) AS totalEf4 " strSQL6 = strSQL6 & " From Ramal , CRJJ04 " strSQL6 = strSql6 & " WHERE Ramal.Ramal=CRJJ04.Origem " strSQL6 = strSQL6 & " And grupo Like '%" & Setor & "%' And Tipo = 0 " strSQL6 = strSQL6 & " GROUP BY Origem " strSQL6 = strSQL6 & " ORDER BY 1 Asc " Set rsCRJJ0425 = conexaodb.Execute(strSQL6) strSQL7 = " Select Origem , COUNT ( * ) AS totalEf5 " strSQL7 = strSQL7 & " From Ramal , CRJJ04 " strSQL7 = strSql7 & " WHERE Ramal.Ramal=CRJJ04.Origem " strSQL7 = strSQL7 & " And grupo Like '%" & Setor & "%' And Tipo = 1 " strSQL7 = strSQL7 & " GROUP BY origem " strSQL7 = strSQL7 & " ORDER BY 1 Asc " Set rsCRJJ0426 = conexaodb.Execute(strSQL7) strSQL8 = " Select '%" & Setor & "%', COUNT ( * ) AS totalEf6 " strSQL8 = strSQL8 & " From Ramal , CRJJ04 " strSQL8 = strSql8 & " WHERE Ramal.Ramal=CRJJ04.Origem " strSQL8 = strSQL8 & " And grupo Like '%" & Setor & "%' And Tipo = 0 " strSQL8 = strSQL8 & " GROUP BY Ramal.grupo " strSQL8 = strSQL8 & " ORDER BY 1 Asc " Set rsCRJJ0427 = conexaodb.Execute(strSQL8) strSQL9 = " Select '%" & Setor & "%', COUNT ( * ) AS totalEf7 " strSQL9 = strSQL9 & " From Ramal , CRJJ04 " strSQL9 = strSql9 & " WHERE Ramal.Ramal=CRJJ04.Origem " strSQL9 = strSQL9 & " And grupo Like '%" & Setor & "%' And Tipo = 1 " strSQL9 = strSQL9 & " GROUP BY Ramal.grupo " strSQL9 = strSQL9 & " ORDER BY 1 Asc " Set rsCRJJ0428 = conexaodb.Execute(strSQL9) strSQL10 = " Select Top 10 * , ramal.ramal , CRJJ04.Origem , CRJJ04.duracao , CRJJ04.n_discado , CRJJ04.data " strSQL10 = strSQL10 & " From Ramal " strSQL10 = strSQL10 & " Inner Join CRJJ04 " strSQL10 = strSQL10 & " On Ramal.Ramal = CRJJ04.Origem " strSQL10 = strSQL10& " where tipo = 0 " strSQL10 = strSQL10& " And grupo Like '%" & Setor & "%' And duracao >= 900 " strSQL10 = strSQL10 & "Order BY origem asc " Call abreConexao Set rsCRJJ049 = Conexaodb.Execute(strSQL10) %> <html> <head> <title>Setor</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"> <!-- body, td, th { font-family: Tahoma; font-size: 11px; color: #000000; } .style1 {color: #FFFFFF} body { margin-left: 50px; } .style7 {font-size: 11px} --> </style></head> <body> <table width="705" border="0" cellspacing="1" cellpadding="1"> <tr> <td width="109"> </td> <td width="520"><div align="right"></div></td> <td width="96"><div align="right"><a href="javascript:window.close()"><img src="Figuras/bot_sair%5B1%5D.gif" alt="Sair" width="39" height="13" border="0"></a></div></td> </tr> </table> <table width="701" border="0" cellspacing="1" cellpadding="1"> <tr> <td width="58">Setor:</td> <td width="107"><% = Response.Write("Setor") %></td> <td width="84">Total efetuadas: </td> <td width="69"><% = rsCRJJ0427 ( "totalEf6" ) %></td> <td width="80">Total recebidas:</td> <td width="70"><% = rsCRJJ0428( "totalEf7" ) %></td> <td width="70"><a href="Sumario_mes.html"><img src="Figuras/bot_voltar2.gif" alt="Voltar" width="50" height="8" border="0"></a></td> <td width="72"><a href="javascript:Self:print()"><img src="Figuras/btn_imprimir.gif" alt="Imprimir Documento" width="72" height="22" border="0"></a></td> <td width="63"><div align="right"></div></td> </tr> </table> <table width="701" border="0"> <tr> <td width="695" height="23"><hr align="left" width="600" color="#000000"></td> </tr> </table> <table width="706" border="0" cellspacing="1" cellpadding="1"> <tr> <td width="48" bgcolor="#003366"><div align="center"><span class="style1">Ramal</span></div></td> <td width="76" bgcolor="#003366"><div align="center"><span class="style1">Ligações locais</span></div></td> <td width="93" bgcolor="#003366"><div align="center"><span class="style1">Ligações regionais </span></div></td> <td width="77" bgcolor="#003366"><div align="center"><span class="style1">Ligações DDD </span></div></td> <td width="84" bgcolor="#003366"><div align="center"><span class="style1">Ligações Celular</span></div></td> <td width="81" bgcolor="#003366"><span class="style1">Total efetuadas</span></td> <td width="87" bgcolor="#003366"><div align="center"><span class="style1">Total recebidas </span></div></td> <td width="135"> </td> </tr> </table> <% DO UNTIL rsCRJJ0421.EOF %> <table border="0" cellpadding="1" cellspacing="1" width="708"> <tr> <td width="51" > <div align="center" class="style7"> <% = rsCRJJ0421.fields( "Origem" ) %> </div></td> <td width="75" > <div align="center" class="style7"> <% If not rsCRJJ0421.EOF Then Response.Write rsCRJJ0421("totalEf") end if %> </div></td> <td width="93" ><div align="center" class="style7"> <% If Not rsCRJJ0422.EOF Then Response.Write rsCRJJ0422( "totalEf1" ) end if %> </div></td> <td width="75" ><div align="center" class="style7"> <% If Not rsCRJJ0423.EOF Then Response.Write rsCRJJ0423( "totalEf2" ) end if %> </div></td> <td width="85" ><div align="center" class="style7"> <% If IsNull(rsCRJJ0424("TotalEf3")) or rsCRJJ0424("totalEF3") = "" Then Response.Write 0 Else Response.Write rsCRJJ0424("totalEF3") end if %> </div></td> < <td width="79" ><div align="center" class="style7"> <% If Not rsCRJJ0425.EOF Then Response.Write rsCRJJ0425( "totalEf4" ) end if %> </div></td> <td width="89" ><div align="center" class="style7"> <% If IsNull(rsCRJJ0424("TotalEf3")) or rsCRJJ0424("totalEF3") = "" Then Response.Write 0 Else Response.Write rsCRJJ0424("totalEF3") end if %> <% If Not rsCRJJ0426.EOF Then Response.Write rsCRJJ0426( "totalEf5" ) end if %> </div></td> <td width="136" > <div align="center"><span class="style7"> </span> </div></td> </tr> </table> <% 'rsCRJJ042.MoveNext rsCRJJ0421.MoveNext rsCRJJ0422.MoveNext rsCRJJ0423.MoveNext rsCRJJ0424.MoveNext rsCRJJ0425.MoveNext rsCRJJ0426.MoveNext Loop 'RsCRJJ042.close 'RsCRJJ0421.close 'Set RsCRJJ042 = nothing 'Set RsCRJJ0421 = nothing %> <table width="701" border="0"> <tr> <td width="695" height="23"> <hr align="left" width="600" color="#000000" size="1"></td> </tr> </table> <p>Ligações do setor com tempo de duração superior a <strong>15 minutos:</strong></p> <table width="550" border="0" cellspacing="1" cellpadding="1"> <tr> <td width="100"><div align="center"><strong><u>Ramal</u></strong></div></td> <td width="100"><div align="center"><strong><u>Numero Discado </u></strong></div></td> <td width="100"><div align="center"><strong><u>Data</u></strong></div></td> <td width="100"><div align="center"><strong><u>Hora</u></strong></div></td> <td width="100"><div align="center"><strong><u>Duração</u></strong></div></td> </tr> <tr> <td width="100" height="34"> <hr style="border-style: dotted; border-width: 1" color="#000000" width="80" size="1"> </td> <td width="100"> <hr style="border-style: dotted; border-width: 1" color="#000000" width="95" size="1"> <div align="center"></div></td> <td width="100"> <hr style="border-style: dotted; border-width: 1" color="#000000" width="80" size="1"> </td> <td width="100"> <hr style="border-style: dotted; border-width: 1" color="#000000" width="80" size="1"> </td> <td width="100"> <hr style="border-style: dotted; border-width: 1" color="#000000" width="80" size="1"> </td> </tr> </table> <table border="0" cellpadding="3" cellspacing="0" width="550"> <% do while not rsCRJJ049.Eof %> <tr> <td width="100"><div align="center" class="style7"> <% = rsCRJJ049.Fields("origem") %> </div></td> <td width="100"><div align="center" class="style7"> <% = rsCRJJ049.Fields("n_discado") %> </div></td> <td width="100"><div align="center" class="style7"> <% = rsCRJJ049.Fields("Data") %> </div></td> <td width="100"><div align="center" class="style7"> <% = rsCRJJ049.fields("Hora") %> </div></td> <td width="100"><div align="center" class="style7"> <% = rsCRJJ049.Fields("duracao") %> Segundos </div></td> </tr> <% rsCRJJ049.MoveNext Loop rsCRJJ049.Close Call fechaConexao Set rsCRJJ049 = Nothing %> </table> <table width="560" border="0"> <tr> <td width="695" height="23"> <hr align="left" width="550" color="#000000" size="1" style="border-style: dotted; border-width: 1"></td> </tr> </table> <p> </p> </body> </html>