Forums

This topic is locked

Event sort: Where startDate and EndDate and Area

Posted 11 Apr 2002 03:54:11
1
has voted
11 Apr 2002 03:54:11 Garo Maka posted:
Im working on a event function.
- Search page has 2 txtFields for FromDate and ToDate, and one selField for Location.
- Result page sorts out according to these three.

Im trying the following, but sorting only works with the selAmt (location):

<%
varWhereString = "WHERE Event_ID <> -1"

IF Request("txtFromDate" <>"" Then
AndFromDateString = " AND Start_Date >= '%" & Request("txtFromDate" & "%'"
Else
AndFromDateString = ""
End If

IF Request("txtToDate" <>"" Then
AndToDateString = " AND End_Date <= '%" & Request("txtToDate" & "%'"
Else
AndToDateString = ""
End If

IF Request("selAmt" <>"" Then
AndAmtString = " AND Amt LIKE '%" & Request("selAmt" & "%'"
Else
AndAmtString = ""
End If

varWhereString = varWhereString & AndFromDateString & AndToDateString & AndAmtString
%>
<%
set rsDate = Server.CreateObject("ADODB.Recordset"
rsDate.ActiveConnection = MM_connDezzPortal_STRING
rsDate.Source = "SELECT * FROM tblEvents " &varWhereString
rsDate.CursorType = 0
rsDate.CursorLocation = 2
rsDate.LockType = 3
rsDate.Open()
rsDate_numRows = 0
%>

I gues it has to do with the way I define the request for the dates, but I cant figured out.

Help is apreciated

Replies

Replied 11 Apr 2002 04:17:34
11 Apr 2002 04:17:34 Owen Eastwick replied:
Try it like this:

AndFromDateString = " AND Start_Date >= #" & Request("txtFromDate" & "#"

AndToDateString = " AND End_Date <= #" & Request("txtToDate" & "#"

Bear in mind that the format of the date will have to match that of the database otherwis it will screw up.

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 11 Apr 2002 06:13:27
11 Apr 2002 06:13:27 Garo Maka replied:
Thaks Owen!
Works fine, although it switches the month with the date, even though I write the same format as in the database table.

I will try to figure out how to change this later, got to get some sleep now.

Thank you very much, your my hero
Greetings Fredski

Reply to this topic