How do I get a search to show me more than one result.



I am carrying out a search on an MS Access 2000 db from within a page.
I know that there is more than one result to be displayed, but I can't
get the code to loop to the second result onwards. This is the code.

I hope it's not too big, as I don't want to end up with a thick ear.

<div id="masterdiv">

Dim cn
Dim rs
Dim theVariable
Dim rsSearchResult 'database Recordset Variable
Dim sarySearchWord 'Holds the keywords for the URL
Dim strSearchKeywords 'Holds the keywords to be searched
menuNum = 1
Set CN=CreateObject("ADODB.COnnection")
CN.Open strCon

Set RS=CN.Execute("SELECT nav FROM Nav")
Do While not RS.EOF
Response.Write "<div class=""menutitle""
onclick=""SwitchMenu('sub" & menuNum & "')"">"
Response.Write theVariable & "</div>"
Response.Write "<span class=""submenu"" id=""sub" & menuNum &

Set rsSearchResult = Server.CreateObject("ADODB.Recordset")

strSearchKeywords = Trim(Request.QueryString("search"))

sarySearchWord = Split(Trim(strSearchKeywords), " ")

strSQL = "SELECT Pages.* FROM Pages "

strSQL = strSQL & "WHERE cat LIKE '%" & theVariable & "%'"

rsSearchResult.Open strSQL, strCon

Response.Write vbCrLf & vbCrLf
Response.Write vbCrLf & " <a href=""" & rsSearchResult("cat") & """>"
& rsSearchResult("title") & "</a>"
Response.Write vbCrLf & " </span>"

menuNum = menuNum+1
Set RS=nothing
Set CN=nothing
Set SearchResult=nothing


Thanks in advance




Alex Goodey

you loop on the RS recordset but not the rsSearchResult record set, try
using a Do While like you already have on both Record Sets

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question