Hi
This code isn't mine but I have been asked to look at amending it.
The page displays a number of pics the references are held in an access DB. I want to display them in a particular order using the order by statement. It also has a search function.
My problem is that the 'order by' must go after the 'where' and I can't figure out where to put it.
Currently the pics are displayed in the order they were entered into the DB. They each have pattern numbers which I would like to use to display.
I have made several attempts using 'order by patternNo'. I can get the pics to display in the correct order but then it messes up the search function. I can get the search function to display in order but not general display. I obviously want both to display in order of patternNo.
Here is the URL
http://www.baileydecal.co.uk/cgi-bin/patterns.asp
I have put in a couple of response.writes to help.
Any advice would be great.
Thanks
MArk
strSQL = "SELECT PatternID,c.Category,PatternNo,PatternName,Descrip t " & _
"FROM Pattern p " & _
"INNER JOIN Category c ON p.CategoryID=c.CategoryID "
strWhere = "WHERE "
If strCategoryID <> "0" Then _
strWhere = strWhere & "p.CategoryID = " & strCategoryID & " AND "
If strChkNew = "1" Then _
strWhere = strWhere & "New=-1 AND "
If strChkOffer = "1" Then _
strWhere = strWhere & "Offer=-1 AND "
If not request("txtPat") = "" Then _
strWhere = strWhere & "PatternNo like '%" & request("txtPAT") & "%' AND "
If Len(strWhere) > Len("WHERE ") Then
strWhere = Left(strWhere,Len(strWhere)-4)
strSQL = strSQL & strWhere
End If