Whenever the user selects a new course name from the combo box, Enroll must “requery” the CSectionSet
recordset to refresh its records. By selecting a new course name, the user will see records only for the class sections of that course name. The existing CSectionSet
recordset contains records for the previous course name. Requerying the recordset brings it up to date for the new course name, using the current values of the filter and sort strings.
When the user accepts a selection in the combo box, the CSectionForm
record view gets a CBN_SELENDOK notification message. The record view uses its handler for this message to reselect records based on the course name selected, passing the course ID as a parameter.
The following procedure describes how to use WizardBar to create this handler.
To requery the CSectionSet recordset
IDC_COURSELIST
.CBN_SELENDOK
.OnSelendokCourselist
.if (!m_pSet->IsOpen() )
return;
m_ctlCourseList.GetLBText(m_ctlCourseList.GetCurSel(),
m_pSet->m_strCourseIDParam);
m_pSet->Requery();
if (m_pSet->IsEOF())
{
m_pSet->SetFieldNull(&(m_pSet->m_CourseID), FALSE);
m_pSet->m_CourseID = m_pSet->m_strCourseIDParam;
}
UpdateData(FALSE);
This code requeries records from the database into the recordset, based on the parameter value in m_strCourseIDParam
. The parameter value is set to the currently selected course name from the Course List combo box before requerying the database.
If you requery and it turns out that the selected course name has no class sections, the recordset is initialized with Null database field values except for CourseID. (In database terminology, Null means "having no value" and is not the same as NULL in C++.)
If you are working through the DaoEnrol tutorial, at this point you are ready to compile and run the application. After you have examined the working application, return to DaoEnrol Step 3.