Re: Time comfusion
Assuming that your fields are clean date and time fields and not Date/time formatted only to show the parts you want to see the you can do all of this on the fly in the query
where [date_math] = #29/5/2008# AND ([end_time] > #13:00# AND [end_time] <= #14:30#)
becomes
Where [date_math]+[end_time] between #29/5/2008 13:00:00# AND #29/5/2008 14:30:00#
Brian
OK i admit it. I'm a fool.

i did it the wrong way and i created strings to compare and there was no luck of course. I understand what you're saying and you are right of course.
The thing that i think that is not right in the example with between is that between includes the edges (13:00 and 14:30) i want to be > 13:00 and <= 14:30.
Anyway. I think i am drawning with this problem because there must be major changes in my code. i use these queries in many functions of my code.
I will present the problem exactly as it is hoping that this will help you help me.
The values are entered in the table with a bound form.
In the after update of the form I call a procedure that has a dlookup that
checks if the values are valid (checks if there is a overlap with another
lesson).
this dlookup returned a value that it shouldn't that's why i did the queries
i mentioned.
the code goes like this:
Private Sub Form_AfterUpdate()
My_Red = Find_Symptosis(0, Me.aa, Me.Theory, Me.date_math, Format(Me.start_time, "Short Time"), Format(Me.end_time, "Short Time"), Me.hours, Me.BARCODE, Me.teacher, GLOBAL_Vehicle_Barcode, Me.Canceled, Me.unwritten)
if My_Red > 0 then msgbox("Overlap!!!")
end sub
Public Function Find_Symptosis(ByVal idr, aa1, Theor, Datemath, starttime, endtime, Hour, BARC, Teach, veh, Canc, Unwrit) As Integer
CriteriaStr = andID & " AND [date_math] = " & "#" & Format(Datemath,
"mm/dd/yyyy") & "#" & _
" AND NOT [canceled] AND NOT [unwritten] " & _
" AND [teacher] = " & Teach & _
" AND (([start_time] >= " & "#" & Format(starttime, "Short Time") & "#" & _
" AND [start_time] < " & "#" & Format(endtime, "Short Time")
& "#" & " ) " & _
" OR ([end_time] > " & "#" & Format(starttime, "Short Time")
& "#" & _
" AND [end_time] <= " & "#" & Format(endtime, "Short Time")
& "#" & "))"
If Not IsNull(DLookup("[ID]", "[lessons]", CriteriaStr)) Then Sympt = DLookup("[ID]", "[lessons]", CriteriaStr)
if Sympt > 0 then Find_Symptosis = sympt
end function
There is a record in the table that has date_math: 29/05/2008 start_time: 11:30 and end_time: 13:00
when i enter a record with the same date and start_time: 13:00 and end_date 14:30 the dlookup finds a record and tells that there is an overlap. This problem occurs only if the lesson that already exist in the table has start_time before midday and end_time after miday. if BOTH start_time and end_time is before OR after midday there is no problem. For example if there is a record in the table with start_date 08:30 and end time 10:00 and then i add a record with start_time: 10:00 and end time 11:30 the Dlookup will result null (that's good).
These are the parts of my code. in the table the the date_math is declared date/time with short date format and both start_time and end_time are date/time with short time format.
in the form the fields are bound and i have an input mask to enter time and date.
Thank you for your help it is much appreciated!