Hi folks..i am new to this forum and fairly new to asp so hope you bear (bare?)with me
I have an Access2003 DB where i have a query called Attendance Query. I want to run a Search where the users can enter a StartDate and an EndDate and then the results will output in a table for all records within that time frame. i have tried to adapt my other simple text searches for this, but i am not having much luck. My query has the following fields: newDate (date), FullName(text), Reason(text), Justified(Yes/No)
When i run the code i get
Expected end of statementon the sql line, though i am certain that not the only problem here. Here is my code: i have stripped out some of the html stuff to make it more readable.
Code:
<%@ Language=VBScript %>
<%
dim conn
Session.timeout = 2
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "attendance2004","",""
%>
<%
select case request.querystring("Action")
case "Search"
sql="SELECT * FROM attendancequery WHERE newdate BETWEEN #"StartDate"# AND #"EndDate"# "
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, 3, 3
end select
%>
<%
Select case request.querystring("Action")
case "Search"
%>
<table WIDTH="100%" BORDER="0" BGCOLOR="#ffffff" CELLSPACING="0">
<TBODY>
<% Do While Not RS.EOF %>
<% if ucase(rs("justified"))="ON" then
sJustified="Yes"
else
sJustified="No"
end if %>
<tr VALIGN="TOP">
<td><%Response.Write RS("newdate")%></td>
<td><%Response.Write RS("fullname")%></td>
<td><%Response.Write RS("reason")%></td>
<td><%Response.Write sJustified%></td>
</tr>
</font><font COLOR="#000000" FACE="Arial" size="2">
<% RS.MoveNext %>
<% loop %>
</table>
<% case else%>
<form ACTION="reportattendanceByDateA.asp" METHOD="GET">
<font face="Arial">Start Date</font><input NAME="startdate" size="13"><br>
End Date <input type="text" name="enddate" size="14">
<input TYPE="Submit" VALUE="Search" name="Action"></p>
</form>
<p>
<%End Select%>
Anyone got ideas? Also, in my Response.write(s), does the case of the fields have to match ExaCTly the way the field is in my Access DB
many thanks