Hey Guys i was just wandering if you could help me solve the error I come up with
compile error do without loop
Code:
Private Sub cboTime_Enter()
Dim i As Date, n As Integer, oRS As DAO.Recordset
Dim sSQL As String, dDuration As Date
Dim dLowerbreak As Date, dUpperBreak As Date
cboTime.RowSourceType = "Value List"
cboTime.RowSource = ""
If IsNull(Start) Then Exit Sub Else i = Start
If Me.NewRecord = True Then
DoCmd.RunCommand acCmdSaveRecord
End If
sSQL = "SELECT DoctorsID,AppointDate,AppointTime"
sSQL = sSQL & " FROM qrySubformAppoints"
sSQL = sSQL & " WHERE DoctorsID=" & Me.ID & _
" AND AppointDate=#" & Me.txtAppointDate & "#"
Set oRS = CurrentDb.OpenRecordset(sSQL)
dDuration = TimeValue("00:30")
dLowerbreak = Break - TimeValue("00:25") 'Break is a field
dUpperBreak = Break + TimeValue("00:25")
If oRS.RecordCount = 0 Then
Do
If i <= dLowerbreak Or i >= dUpperBreak Then
cboTime.AddItem i
End If
i = i + dDuration
Loop Until i >= txtEnd
Else
Do
If i <= dLowerbreak Or i >= dUpperBreak Then
oRS.FindFirst "[AppointTime] Between #" & i - TimeValue("00:00:05") & _
"# And #" & i + TimeValue("00:00:05") & "#"
If oRS.NoMatch Then cboTime.AddItem i
End If
oRS.Close
End Sub