Primero que nada bienvenid@ al foro, después, es más o menos sencillo solo se tiene que seguir un orden
Código:
'Obtenemos nuestros criterios de busqueda
precio = Request.Form("precio")
metros_cuadrados = Request.Form("metros_cuadrados")
codigo_postal = Request.Form("codigo_postal")
'Una variable que se incremente
argCount = 0
'Nuestra consulta base
strSQL = "SELECT campos FROM tabla "
'Aqui comenzamos a crear la consulta dinamica
if len(precio) > 0 then
if argCount = 0 then
strSQL = strSQL & " WHERE "
else
strSQL = strSQL & " AND "
end if
strSQL = strSQL & " campo_precio <= " & precio
argCount = argCount + 1
end if
if len(codigo_postal) > 0 then
if argCount = 0 then
strSQL = strSQL & " WHERE "
else
strSQL = strSQL & " AND "
end if
strSQL = strSQL & " campo_codigo_postal = " & codigo_postal
argCount = argCount + 1
end if
if len(metros_cuadrados) > 0 then
if argCount = 0 then
strSQL = strSQL & " WHERE "
else
strSQL = strSQL & " AND "
end if
strSQL = strSQL & " campo_metros_cuadrados = " & metros_cuadrados
argCount = argCount + 1
end if
Y asi sucesivamente...
Saludos