Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

Two search criterias again!!?

Posted 28 Jan 2002 13:35:16
1
has voted
28 Jan 2002 13:35:16 Henrik Sandeberg posted:
I have a databse with some fields. fields= mobnr,enamn,fnamn,telnr. I want to have an listbox where i can select the field name and then a textbox where i can search for example the number. I wrote an Sql query like this:

SELECT * FROM database WHERE '%listbox%' LIKE '%searchword%'

param:
listbox % Request.QueryString("listbox"
searchword % Request.QueryString("searchword"

If i hardcode the sql query like:

SELECT * FROM database WHERE mobnr LIKE '%searchword%'

it will work, but not when i have the listbox in the script.,,

/Henrik

Replies

Replied 28 Jan 2002 14:32:23
28 Jan 2002 14:32:23 Owen Eastwick replied:
Try making the whole WHERE clause dynamic. e.g.

strSQL = "WHERE " & Request("ListBoxName" & " LIKE '%" & Replace(Request("SearchBoxName", "'", "''" & "%'"

Then:

RecordsetName.Source = "SELECT * FROM TableName " & strSQL

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 28 Jan 2002 14:46:30
28 Jan 2002 14:46:30 Henrik Sandeberg replied:
ok, i will try now......

/H

Replied 28 Jan 2002 15:03:03
28 Jan 2002 15:03:03 Henrik Sandeberg replied:
Im using UD 4, how do implemet this into it., can i write this srtSql direct in the codeview.

/Henrik

Replied 28 Jan 2002 16:40:08
28 Jan 2002 16:40:08 Owen Eastwick replied:
Yes, set up a standard recordset using the data bindings window, then modify the relevant lines of code directly in code view.

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 29 Jan 2002 09:29:17
29 Jan 2002 09:29:17 Henrik Sandeberg replied:
Thanx, it works great.!

Reply to this topic