Step 2 implemented a handler for selecting a course in the combo box. The handler requeried the parameterized CSectionSet
for the newly selected course. In Step 3, the combo box takes on the additional duty of allowing the user to specify the course for a new section record being added. During add mode, you don’t want to requery the recordset when the user selects a course from the combo box. Therefore, you need to put the requery logic inside an if clause that is executed only if add mode isn’t in effect.
To disable normal combo box logic while in add mode
OnSelendokCourseList
handler in class CSectionForm
.OnSelendokCourseList
handler, so the handler now appears as follows:void CSectionForm::OnSelendokCourselist()
{
m_ctlCourseList.GetLBText(m_ctlCourseList.GetCurSel(),
m_pSet->m_strCourseIDParam);
if (!m_bAddMode)
{
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);
}
}