Hi
I was wondering what the logic to use for comparing 2 recordsets.
I have a RSCourseAttendedByStaff recordset (which is a list of staff members who have done a specific training course)
My other recordset, RSAllStaff, is a full list of staff members.
I want to compare the two and find out any names from RSAllStaff who have not done the specified course (i.e. who are not present in the RSCourseAttendedByStaff).
I have started the code...
I was wondering what the logic to use for comparing 2 recordsets.
I have a RSCourseAttendedByStaff recordset (which is a list of staff members who have done a specific training course)
My other recordset, RSAllStaff, is a full list of staff members.
I want to compare the two and find out any names from RSAllStaff who have not done the specified course (i.e. who are not present in the RSCourseAttendedByStaff).
I have started the code...
Code:
Private Sub cmdCourse_Click()
Dim SQLCourseAttendedByStaff, SQLAllStaff As String
Dim RSCourseAttendedByStaff As New Recordset
Dim RSAllStaff As New Recordset
List1.Clear
If cmbCourse.Text = "" Then
MsgBox "Course Required", vbInformation, "Select from List"
cmbCourse.SetFocus
Exit Sub
Else
Open_cn
SQLCourseAttendedByStaff = "SELECT Name, Course From TrainingRecord WHERE (Course = '" & cmbCourse & "') ORDER BY Name"
SQLAllStaff = "SELECT DISTINCT Name FROM TraininRecord ORDER BY Name"
RSCourseAttendedByStaff.Open SQLCourseAttendedByStaff, cn, adOpenStatic, adLockOptimistic, adCmdText 'create the recordset
RSAllStaff.Open SQLCourseAttendedByStaff, cn, adOpenStatic, adLockOptimistic, adCmdText 'create the recordset
'... loop to compare results
'List1.AddItem RSCourseAttendedByStaff.Fields("Name") 'If they are a staff member but not on the SQLCourseAttendedByStaff list then add to listbox
End If
Close_cn
End Sub