I have this code
[CODE=vb]Public Function Duplicate(ByRef adRecordset As ADODB.Recordset , ByRef Subject As _
String, ByRef Course As String) As Boolean
Duplicate = False 'Default value
'Opens and checks the connection
SetConnection
CheckConnection adRecordset
adRecordset.Ope n "Select SubjectCode From LoadSchedules Where SubjectCode='" & _
Subject & "' And Courses.Title=' " & Course & "'", dbConnection, 1, 1
'Checks if there is duplicate subject
If adRecordset.Rec ordCount > 0 Then
Duplicate = True
Else
Duplicate = False
End If
Set dbConnection = Nothing
End Function
'============== =============== =======
Public Sub Update(ByVal ScheduleID As String, ByRef SubjectCode As String, ByRef _
Lecture As Integer, ByRef Laboratory As Integer, ByRef StartTime As Date, ByRef EndTime _
As Date, ByRef DayID As String, ByRef RoomID As String, adForm As Form)
'Opens and checks the connection
SetConnection
'CheckConnectio n adRecordset
'Update course
dbConnection.Ex ecute "Update Schedules Set [SubjectCode]='" & SubjectCode & _
"',[Lecture]=" & Lecture & ",[Laboratory]=" & Laboratory & ",[StartTime]=#" & _
StartTime & "#,[EndTime]=#" & EndTime & "#,[DayID]='" & DayID & "'," & _
"[RoomID]='" & RoomID & "' Where [ScheduleID]='" & ScheduleID & "'"
Unload adForm
frmSchedules.Lo adSchedules
MsgBox ScheduleID & " has been successfully updated.", 64, "Updated Schedule"
frmSchedules.Lo adSchedules
Set dbConnection = Nothing
Exit Sub
End Sub
[/CODE]
I use the duplicate function to check if the subject is already existing before the update function, now my problem is this, I can only update subject if modify it. How can I update the schedule without prompting existing? Hope you understand my post
Rey Sean
[CODE=vb]Public Function Duplicate(ByRef adRecordset As ADODB.Recordset , ByRef Subject As _
String, ByRef Course As String) As Boolean
Duplicate = False 'Default value
'Opens and checks the connection
SetConnection
CheckConnection adRecordset
adRecordset.Ope n "Select SubjectCode From LoadSchedules Where SubjectCode='" & _
Subject & "' And Courses.Title=' " & Course & "'", dbConnection, 1, 1
'Checks if there is duplicate subject
If adRecordset.Rec ordCount > 0 Then
Duplicate = True
Else
Duplicate = False
End If
Set dbConnection = Nothing
End Function
'============== =============== =======
Public Sub Update(ByVal ScheduleID As String, ByRef SubjectCode As String, ByRef _
Lecture As Integer, ByRef Laboratory As Integer, ByRef StartTime As Date, ByRef EndTime _
As Date, ByRef DayID As String, ByRef RoomID As String, adForm As Form)
'Opens and checks the connection
SetConnection
'CheckConnectio n adRecordset
'Update course
dbConnection.Ex ecute "Update Schedules Set [SubjectCode]='" & SubjectCode & _
"',[Lecture]=" & Lecture & ",[Laboratory]=" & Laboratory & ",[StartTime]=#" & _
StartTime & "#,[EndTime]=#" & EndTime & "#,[DayID]='" & DayID & "'," & _
"[RoomID]='" & RoomID & "' Where [ScheduleID]='" & ScheduleID & "'"
Unload adForm
frmSchedules.Lo adSchedules
MsgBox ScheduleID & " has been successfully updated.", 64, "Updated Schedule"
frmSchedules.Lo adSchedules
Set dbConnection = Nothing
Exit Sub
End Sub
[/CODE]
I use the duplicate function to check if the subject is already existing before the update function, now my problem is this, I can only update subject if modify it. How can I update the schedule without prompting existing? Hope you understand my post
Rey Sean
Comment