Hello World
I have a problem in detecting the conflict schedule (Day and Time).
Day
1. M
2. T
3. W
4. TH
5. F
6. S
7. M/TH <---My problem :(
8. T/F <---My problem :(
9. W/S <---My problem :(
Where: (M='Monday', [T]='Tuesday', and so on...)
Let's say I have this existing schedule on my database:
Here's my sample code and it is working but if the Day='M/TH' or Day='T/F' or Day='T/F' it can save the record even if it has already a schedule for that (refer to sample above).
[code=vb]
Public Function Conflict(ByRef adConnection As ADODB.Connectio n, ByRef adRecordset _
As ADODB.Recordset , ByRef Day As String, ByRef Room As _
String, ByRef Course As String, ByRef TimeStarted As Date, ByRef TimeFinished As _
Date) As Boolean 'ByRef Subject As String,
Conflict = False 'Default value
'Opens and checks the connection
SetConnection
CheckConnection adRecordset
adRecordset.Ope n "Select * From LoadSchedules Where " & _
"Day='" & Day & "' And Rooms.Title='" & Room & "' And Courses.Title=' " & _
Course & "' And (TimeStarted Between #" & TimeStarted & "# And #" & _
TimeFinished & "# Or TimeFinished Between #" & TimeStarted & "# And #" & _
TimeFinished & "#)", dbConnection, 1, 1
'Checks if there is duplicate title
If adRecordset.Rec ordCount > 0 Then
Conflict = True
Else
Conflict = False
End If
End Function
[/code]
Any solution will be greatly appreciated : )
Rey Sean
I have a problem in detecting the conflict schedule (Day and Time).
Day
1. M
2. T
3. W
4. TH
5. F
6. S
7. M/TH <---My problem :(
8. T/F <---My problem :(
9. W/S <---My problem :(
Where: (M='Monday', [T]='Tuesday', and so on...)
Let's say I have this existing schedule on my database:
Code:
Monday(Day) 7:00 AM(TimeIN) 8:00 AM(TimeOut) AVR(Rooom)
[code=vb]
Public Function Conflict(ByRef adConnection As ADODB.Connectio n, ByRef adRecordset _
As ADODB.Recordset , ByRef Day As String, ByRef Room As _
String, ByRef Course As String, ByRef TimeStarted As Date, ByRef TimeFinished As _
Date) As Boolean 'ByRef Subject As String,
Conflict = False 'Default value
'Opens and checks the connection
SetConnection
CheckConnection adRecordset
adRecordset.Ope n "Select * From LoadSchedules Where " & _
"Day='" & Day & "' And Rooms.Title='" & Room & "' And Courses.Title=' " & _
Course & "' And (TimeStarted Between #" & TimeStarted & "# And #" & _
TimeFinished & "# Or TimeFinished Between #" & TimeStarted & "# And #" & _
TimeFinished & "#)", dbConnection, 1, 1
'Checks if there is duplicate title
If adRecordset.Rec ordCount > 0 Then
Conflict = True
Else
Conflict = False
End If
End Function
[/code]
Any solution will be greatly appreciated : )
Rey Sean
Comment