How to prevent overlapping schedules?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Wiretwisterz
    New Member
    • Mar 2008
    • 27

    #61
    So you're saying the time fields should be appended to the end of the date field(s)?

    Sorry, trying to make sure I understand what it was you're suggesting.

    Thanks,

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #62
      Code:
      Dim strFilter As String, strFormat As String
      Dim datStartEnd As Date
      
      strFormat = "m/d/yyyy HH:nn:ss"
      strFilter = "(([Building]='%B') AND " & _
                  "([Location]='%L') AND " & _
                  "([StartDate]+[StartTime]<=#%E#) AND " & _
                  "([EndDate]+[EndTime]>=#%S#))"
      strFilter = Replace(strFilter, "%B", Me.Building)
      strFilter = Replace(strFilter, "%L", Me.cmbLocation)
      datStartEnd = CDate(Me.cmbEndDate & " " & Me.txtEndTime)
      strFilter = Replace(strFilter, "%E", Format(datStartEnd, strFormat))
      datStartEnd = CDate(Me.cmbStartDate & " " & Me.txtStartTime)
      strFilter = Replace(strFilter, "%S", Format(datStartEnd, strFormat))
      
      If DCount("[StartDate]", "[Events]", strFilter) > 0 Then
      Call MsgBox("Selected Range overlaps an existing range in the table")
      Cancel = True
      End If

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #63
        Originally posted by Wiretwisterz
        So you're saying the time fields should be appended to the end of the date field(s)?

        Sorry, trying to make sure I understand what it was you're suggesting.

        Thanks,
        Essentially yes.

        Have a look at how I've done it in the code and see if that makes sense to you.

        Comment

        Working...