Going to post what I have so I can hopefully close this out. You can try this in your event (not sure what that is - AfterUpdate of the StartTime textbox?). If that is the case, the 'successful' message may not be adequate. Assumes your time fields are compatible with my chosen variable type (Double).
Code:
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim strSql As String
Dim dblEnd As Double, dblStart As Double, dblNewTime As Double '??
Dim i As Integer
On Error GoTo errHandler
strSql = "SELECT AppointmentDate, StartTime, EndTime FROM AppointmentTbl WHERE"
strSql = strSql & " AppointmentDate = #" & Me.AppointmentDateTxt & "#"
Set db = CurrentDb
'open recordset based on strSql
Set rs = db.OpenRecordset(strSql)
If Not (rs.BOF And rs.EOF) Then 'if Not, then there are records
dblNewTime = Me.StartTimeTxt
Do Until rs.EOF
dblStart = rs.Fields("StartTime")
dblEnd = rs.Fields("EndTime")
If dblNewTime > dblStart And dblNewTime < dblEnd Then i = i + 1
rs.MoveNext
Loop
End If
If i > 0 Then
MsgBox "There are " & i & " conflicting appointments for that time on " & Me.AppointmentDateTxt
Else
MsgBox "Appointment creation successful"
End If
exitHere:
On Error Resume Next
rs.Close
Set rs = Nothing
Set db = Nothing
Exit Sub
errHandler:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume exitHere