Devo effettuare una ricerca in una tabella solo ed esclusivamente nei records che hanno il campo TipoDocumento='ORDINE'.

Ho provato con il seguente codice ma a volte i risultati comprendono anche i records con il campo TipoDocumento diverso da 'ORDINE'

Dov'è che sbaglio?

codice:

codice:
testo = "" & Request.Querystring("Cerca")
trova = Split(testo, " ")

sql = "SELECT * FROM Preventivo WHERE TipoDocumento='ORDINE' AND "

 For i = 0 To UBound(trova)
   If i > 0 Then
       sql = sql & " AND"
    End If

sql = sql & " Cliente LIKE '%" + trova(i) + "%' OR Riferimento LIKE '%" + trova(i) + "%' OR NumeroPreventivo LIKE '%" + trova(i) + "%' OR DataPreventivo LIKE '%" + trova(i) + "%' OR UtenteInserimento LIKE '%" + trova(i) + "%' " 

Next


sql = sql & " order by DataPreventivo DESC "


in pratica se cerco 1 la query che stampo è questa:
SELECT * FROM Preventivo WHERE TipoDocumento='ORDINE' AND UtenteInserimento='Luca' AND Cliente LIKE '%1%' OR Riferimento LIKE '%1%' OR NumeroPreventivo LIKE '%1%' OR DataPreventivo LIKE '%1%'