Why not do something like this?

<%
dteStartTime = Request.Form("txtStartTime")
dteEndTime = Request.Form("txtEndTime")

If not isDate(dteStartTime) then
' Error
End If

If not isDate(dteEndTime) then
' Error
End If

strSQL = _
"SELECT COUNT(*) " & _
"FROM Bookings " & _
"WHERE " & dteStartTime & " <= EndTime " & _
"AND " & dteEndTime & " >= StartTime"

' Open connection here
objConn.Open blah blah

Set objRS = objConn.Execute(strSQL)

If objRS.EOF then
' overlapping booking
' error
Else
' not overlapping booking
End If
%>

Cheers
Ken




"Julie" <anonymous@discussions.microsoft.com> wrote in message
news:EE8EF5F2-4ED4-4628-9B95-EEE7AFFE3218@microsoft.com...
: Hello, I'm using Access 2002 and I want someone to enter a date and time
from a webform and have that data checked against the database to see if it
is available. Below is some code that I'm using, but it isn't working
correctly. TIA
:
: ' get the number of records
: SQL2 = "SELECT COUNT(id) FROM table"
: Set RS2 = server.createobject("ADODB.Recordset")
: set RS2=conn.execute(SQL2)
: y = RS2.Fields(0)
: last = y - 1
:
: ' select all but the last record entered
: SQL = "SELECT TOP " & last & " * FROM table ORDER BY id"
: Set RS = server.createobject("ADODB.Recordset")
: set RS=conn.execute(SQL)
:
: ' sort records by Desc order
: SQL8 = "SELECT id FROM table ORDER BY id DESC"
: Set RS8 = server.createobject("ADODB.Recordset")
: set RS8=conn.execute(SQL8)
: l = RS8.Fields(0)
:
: ' select the last record
: SQLlast = "SELECT datereq, timereq, endtime FROM truck WHERE id = " & l
: Set RSl = server.createobject("ADODB.Recordset")
: Set RSl = conn.execute(SQLlast)
:
: ' Below is the loop that isn't working ???
:
: While not RS.EOF
:
: If RSl.Fields("datereq") = RS.Fields("datereq") AND RSl.Fields("timereq")
>= RS.Fields("timereq") AND RSl.Fields("timereq") < RS.Fields("endtime")
Then
:
: Response.Write("That time is unavailable! " &
TimeWithoutSeconds(RS.Fields("timereq")) & " " &
TimeWithoutSeconds(RS.Fields("endtime")) & " is already scheduled!" &
"<br>")
: SQLDel = "DELETE FROM table WHERE id =" & x
: conn.execute(SQLDel)
: Response.Write "<" & "script language='JavaScript'>" & _
: "window.alert("" Start Time is unavailable! ""); " & _
: "history.go(-1); " & _
: "</script>"
:
: Else
:
: Response.Write(RS.Fields("datereq") & "&nbsp;")
: Response.Write("&nbsp;")
:
: If RS.Fields("leave") = false Then
: Response.Write(TimeWithoutSeconds(RS.Fields("timer eq")))
: Response.Write("&nbsp;" &
TimeWithoutSeconds(RS.Fields("endtime")) & "<br>")
: Else
: Response.Write("Time Not Available.")
: End If
:
: End If
:
: RS.MoveNext
: WEnd
: