Ciao a tutti, ho il seguente codice, dove per ogni agente estratto dalla tabella personale deve eseguire il ciclo sotto, solo che mi da l'errore:

Errore di run-time di Microsoft VBScript error '800a000d'

Tipo non corrispondente

/Gestionale_vers_121_B/analisi/storico_fatturato.asp, line 219


codice:
<% 
   anno = Request.Form("anno")
if anno <> "" Then  ' se anno



Set rs8 = Server.CreateObject("ADODB.Recordset")
SQL8 = "SELECT * FROM personale  "  '************************ SELEZIONA ED ESTRAI TUTTI GLI AGENTI
		rs8.Open SQL8, conn, 1, 1
  
		 Do while not rs8.EOF
  %>
  
   
   <%

	Dim mes(13)
	
	Set rs10 = Server.CreateObject("ADODB.Recordset")
	Set rs20 = Server.CreateObject("ADODB.Recordset")
	
	a = 1
	Do while not a = 13
		mes(a) = 0
		a = a + 1
	Loop
	a = 1
	Do while a < 13
		
		
		
		
	' LINEA 219	SQL = "SELECT * FROM pagamenti WHERE MONTH(data_documento) = '"& a &"' AND"_
			 &" YEAR(data_documento) = '"& anno &"'  AND "_
			 &" (tipo_documento = 'Fattura Scarico' OR tipo_documento = 'Nota Cliente') "
		rs10.Open SQL, conn, 1, 1
		Do while not rs10.EOF
			if rs10("tipo_documento") = "Fattura Scarico" Then
				tipo_doc = "FATTURA ACCOMPAGNATORIA"
			else
				tipo_doc = "NOTA DI ACCREDITO"			
			end if
			data_doc = Year(rs10("data_documento"))&"-"&Month(rs10("data_documento"))&"-"&Day(rs10("data_documento"))
			SQL = "SELECT * FROM fattura_vendita WHERE data_fattura = '"& data_doc &"' AND"_
				 &" codice_fattura = '"& rs10("codice_documento") &"' AND codice_cliente = '"& rs10("codice_cl_fo") &"'"_
				 &"  Order by codice_prodotto"
			rs20.Open SQL, conn, 1, 1
			iva = 0
			b = 0
			Do while not rs20.EOF
				importo_prod = 0
				iva = iva + Cdbl(rs20("iva"))
				importo_prod = Cdbl(rs20("prezzo_scontato") * rs20("quantita"))
				importo_prod = importo_prod + ((importo_prod/100) * Cdbl(rs20("iva")))
				if tipo_doc = "FATTURA ACCOMPAGNATORIA" or tipo_doc = "FATTURA" Then
					mes(a) = mes(a) + importo_prod
				else
					mes(a) = mes(a) - importo_prod
				end if
				rs20.MoveNext
				b = b + 1
			Loop
			rs20.Close
			if b > 0 Then
				media_iva = iva/b
			end if
			SQL = "SELECT * FROM fattura_vendita_dati WHERE id_agente = '"& rs8("codice_agente") &"' AND data_documento = '"& data_doc &"' AND"_
				 &" codice_documento = '"& rs10("codice_documento") &"' Order by codice_documento"
			rs20.Open SQL, conn, 1, 1
			Do while not rs20.EOF
				spese = 0
				iva_spese = 0
				spese = CDbl(rs20("spese_bolli")) + CDbl(rs20("spese_trasporto")) + CDbl(rs20("spese_banca")) + CDbl(rs20("spese_varie")) + CDbl(rs20("spese_provvigione")) - CDbl(rs20("omaggio"))
				iva_spese = (spese/100) * media_iva
				spese = spese + iva_spese
				rs20.MoveNext
			Loop
			if tipo_doc = "FATTURA ACCOMPAGNATORIA" or tipo_doc = "FATTURA"  Then
				mes(a) = Round((mes(a) + spese), 2)
			else
				mes(a) = Round((mes(a) - spese), 2)
			end if
			rs20.Close
			rs10.MoveNext
		Loop
		rs10.Close
		a = a + 1
	Loop
	set rs10 = nothing
	set rs20 = nothing
	
	a = 1
	mes_temp = 0
	Do while not a = 13
		if mes(a) > mes_temp Then
			mes_max = mes(a)
			mes_temp = mes(a)
		end if
		a = a + 1
	Loop
	if mes_max > 0 then
		prop = 200/mes_max
	else
		prop = 1
	end if

				%> <%=rs8("nome")%>  <%=rs8("cognome")%>
  <table width="700" border="1" cellspacing="0" bordercolor="#CCCCCC">
  <tr> 
    <td width="650" class="IntestazioneFattura"><font size="2">STORICO FATTURATO</font></td>
  </tr>
  <tr>
    <td class="DatiFatturaNero"><font color="#FF0000" size="2"><%=anno%></font></td>
  </tr>
  <tr> 
    <td align="center"> <table width="600" height="220" border="1" cellpadding="0" cellspacing="0">
        <tr> 
          <td></td>
          <td valign="bottom" class="DatiFatturaNero"><%=mes(1)%>
 [img]../images/gen.gif[/img]"></td>
          <td valign="bottom" class="DatiFatturaNero"><%=mes(2)%>
 [img]../images/feb.gif[/img]"></td>
          <td valign="bottom" class="DatiFatturaNero"><%=mes(3)%>
 [img]../images/mar.gif[/img]"></td>
          <td valign="bottom" class="DatiFatturaNero"><%=mes(4)%>
 [img]../images/apr.gif[/img]"></td>
          <td valign="bottom" class="DatiFatturaNero"><%=mes(5)%>
 [img]../images/mag.gif[/img]"></td>
          <td valign="bottom" class="DatiFatturaNero"><%=mes(6)%>
 [img]../images/giu.gif[/img]"></td>
          <td valign="bottom" class="DatiFatturaNero"><%=mes(7)%>
 [img]../images/lug.gif[/img]"></td>
          <td valign="bottom" class="DatiFatturaNero"><%=mes(8)%>
 [img]../images/ago.gif[/img]"></td>
          <td valign="bottom" class="DatiFatturaNero"><%=mese(9)%>
 [img]../images/set.gif[/img]"></td>
          <td valign="bottom" class="DatiFatturaNero"><%=mes(10)%>
 [img]../images/ott.gif[/img]"></td>
          <td valign="bottom" class="DatiFatturaNero"><%=mes(11)%>
 [img]../images/nov.gif[/img]"></td>
          <td valign="bottom" class="DatiFatturaNero"><%=mes(12)%>
 [img]../images/dic.gif[/img]"></td>
        </tr>
        <tr> 
          <td width="40" height="20" class="DatiFatturaNero">**</td>
          <td width="35" height="20" class="DatiFatturaNero">Gen</td>
          <td width="35" height="20" class="DatiFatturaNero">Feb</td>
          <td width="35" height="20" class="DatiFatturaNero">Mar</td>
          <td width="35" height="20" class="DatiFatturaNero">Apr</td>
          <td width="35" height="20" class="DatiFatturaNero">Mag</td>
          <td width="35" height="20" class="DatiFatturaNero">Giu</td>
          <td width="35" height="20" class="DatiFatturaNero">Lug</td>
          <td width="35" height="20" class="DatiFatturaNero">Ago</td>
          <td width="35" height="20" class="DatiFatturaNero">Set</td>
          <td width="35" height="20" class="DatiFatturaNero">Ott</td>
          <td width="35" height="20" class="DatiFatturaNero">Nov</td>
          <td width="35" height="20" class="DatiFatturaNero">Dic</td>
        </tr>
      </table></td>
  </tr>

</table>       <%


%>



     <%
     	
			rs8.MoveNext
   Loop  	
			
          conn.close
	set conn = nothing  
    end if
	
	%>
Dove potrebbe essere l'errore?
Grazie mille