hiya, i want a button to check availibility of a booking. Click here to see screenshot.

(i suppose i could put this in the "before update" event of the last combobox but for now, i just want to know how to go about doing this...)

1) The button needs to look at the "tblBookings" table, find records which have [a certain date] in their "date" field.
2) Of those records, find those which are in room [whatever room].
3a) Of those, check to see if any of the records have their "time from" field value, equal to [proposed start time] or [proposed finish time]. if any are equal then flag = 1.
3b) Check to see if any of the records have their "time to" field value, equal to [proposed finish time] or [proposed start time]. if any are equal then flag = 1.
3c) Then get the "time to" and "time from" values, and check to see if [proposed start time] is between them, then check to see if [proposed finishtime] is between them. if any are between then flag = 2.

4)
if (flag is equal to 1) then
error message "times on border of another event"
cancel=true


undo

if (flag is equal to 2) then
error message "times overlap another event"
cancel=true
undo


But, how do i actually implement this?
How do i make it filter the records to look for those with a certain date?
Where do i start?

Thanks,
Ant...