PDA

Click to See Complete Forum and Search --> : database filter procedure


VBfreak
Jan 26th, 2000, 01:15 AM
Could you be more specific and give a bit more details, like examples

pardede
Jan 26th, 2000, 05:18 AM
maybe you can code something like the following (i haven't tested this so there might be some mistakes in it, but just to give you an idea)

for i = 1 to 10
if txtFields(i).Text <> "" then
if sSQLWhere = "" then
sSQLWhere = "WHERE " & txtFields(i).DataField & "= '" & txtFields(i).Text & "' "
else
sSQLWhere = sSQLWhere & "AND " & txtFields(i).DataField & "= '" & txtFields(i).Text & "' "
end if
end if
next i

sSQL = "SELECT * FROM table " & sSQLWhere

dave_c
Jan 26th, 2000, 11:41 AM
my problem is that i have about 10 fields but i need to be able to search my database for any of the fields, i.e a filter thing so it looks at what data entered to search for, then runs the search procedure taking out relevant records. This is put into a temporary file which you can look at. I can do it on principal but not in code. Thanks for your time, help and all dat.
DAVE

jbuck
Jan 26th, 2000, 09:59 PM
Hi,
I have done something similiar to what pardede suggests and it works but you have to add the logic to get out of the loop. What I did was a case statement. that checked the text boxes by priority to set the WHERE statement.
Jim