I have been trying to figure out how to compare a booking entered on a a form by a user with all previous bookings. As long as they do not overlap I would like the record saved. If they do overlap the user will be informed and make another selection. At the moment I am trying to use CASE to evaluate the dates. I will add time once i get this to work. I thought this may work but the debug picks up the refernece to the table (bookings) and thinks it's a field. How or Can, I reference the table properly in a case statement? Should I be looking for a different way to achieve my goals? I have a table for bookings, employees and resources. Also I have a form with the ocx calander for date picking and a resource list and employee list.
Private Sub book_click()
Dim NStart As Date
Dim NEnd As Date
Dim Start As Date
Dim Finish As Date
NStart = Me![StartDate]
NEnd = Me![EndDate]
Start = [Bookings]![StartDate]
Finish = [Bookings]![EndDate]
Select Case NStart
Case Start To Finish
DoCmd.OpenForm "CASE1"
End Select
Select Case NEnd
Case Me![StartDate] To Me![EndDate]
DoCmd.OpenForm "CASE2"
Case Else ' Other values.
DoCmd.OpenForm "CASE3"
End Select
End Sub
Jaydeebe
Private Sub book_click()
Dim NStart As Date
Dim NEnd As Date
Dim Start As Date
Dim Finish As Date
NStart = Me![StartDate]
NEnd = Me![EndDate]
Start = [Bookings]![StartDate]
Finish = [Bookings]![EndDate]
Select Case NStart
Case Start To Finish
DoCmd.OpenForm "CASE1"
End Select
Select Case NEnd
Case Me![StartDate] To Me![EndDate]
DoCmd.OpenForm "CASE2"
Case Else ' Other values.
DoCmd.OpenForm "CASE3"
End Select
End Sub
Jaydeebe