RE:Problemas para realizar consultas con campos va
Hola, tienes q validar cada campo antes de armar la consulta, aqui te pongo mas o menos como debieras hacer la consulta:
...
Dim sql as string
Dim band as boolean
...
band = 0
sql = "Select * from tabla"
if campo1 <> "" then
sql = sql & " where tablacampo1 ='" & campo1 & "'"
band = 1
end if
if campo2 <> "" then
if band = 1 then
sql = sql & " And tablacampo2='" &campo2 & "'"
else
sql = sql & " where tablacampo2='" &campo2 & "'"
band = 1
end if
end if
if campo3 <> "" then
if band = 1 then
sql = sql & " And tablacampo3='" &campo3 & "'"
else
sql = sql & " where tablacampo3='" &campo3 & "'"
band = 1
end if
end if
if campo4 <> "" then
if band = 1 then
sql = sql & " And tablacampo4='" &campo4 & "'"
else
sql = sql & " where tablacampo4='" &campo4 & "'"
band = 1
end if
end if
if campo5 <> "" then
if band = 1 then
sql = sql & " And tablacampo5='" &campo5 & "'"
else
sql = sql & " where tablacampo5='" &campo5 & "'"
band = 1
end if
end if