Buongiorno a tutti.

Per estrarre dei dati da una tabella utilizzo la seguente query:

codice:
SQLDown = "select * From tabella2 WHERE 1=1"

If ucase(trim(Data)) <> "TUTTI" and ut <> 0 then
   SQLDown = "SELECT * FROM TABELLA2 WHERE right(data,4) = "& request("Data") &" "
End If

If ut <> 0 then
   SQLDown = SQLDown & " AND id_ut = "& ut &" "
End if

If cp <> 0 then
  SQLDown = SQLDown & " AND id_cp = "& cp &" "
End If

SQLDown = SQLDown &" order by cp asc"
Funzionano tutte le estrazioni tranne quella per data, infatti nel db la data è prevista come gg/mm/aaaa, con right(data,4) ricavo l'anno, ma la query estrae tutti gli anni e non solo quello selezionato da una select.

Quando stampo la query che dovrebbe estrarre solo i record di quell'anno, ricevo questo:
codice:
select * From tabella2 WHERE 1=1 order by cp asc
Dove sbaglio ???