I'm not sure how to get it to work that way.
I started with an SDI Project from the MFC AppWizard and I chose my view class to de derived from CRecordView. The app will save automatically when the user moves through the record using the premade toolbar buttons or menu options, but it won't save the latest change if the user exits the program without moving throught the record first. I can make a button that saves when clicked by having it run the code:
void somefunction()
{
//check to see if the user created a new record
if (m_UpdateMode) //new record was created
{
UpdateData(TRUE);
if (m_pSet->CanUpdate())
m_pSet->Update();
m_pSet->Requery();
}
else //only edits of current records were made
{
if (m_pSet->CanUpdate())
{
m_pSet->Edit();
UpdateData(TRUE);
m_pSet->Update();
}
}
m_UpdateMode = FALSE;
UpdateData(FALSE);
}
Now if I could put this code in a place that always runs before the View Class is destroyed, I think I'd be set.