Question : How to prevent data loss?

DESCRIPTION
I have noticed an unusual problem on the following form:
frmAHA_NEW_VER1
The Name at the top of the screen (Enter NEW AHA Name) goes away when any of the command buttons are clicked.

PROBLEM BACKGROUND
This problem was notices right after I added the “REQUERY” function to the macros that run the command buttons on the form “frmAHA_NEW_VER1”

TO RECREATE THE PROBLEM
1.      Log into the application
2.      Click “NEW AHA”
3.      Enter a new AHA Title
4.      Click the command  button next to “Developed By”
5.      Now notice the AHA Name. It is gone.
6.      Then if you keep clicking command buttons the error message comes up: See attached image.
Attachments:

Answer : How to prevent data loss?

As in your other Q, you could do some optimizing by stopping the iteration when you encounter a distance that is larger than the one we're checking for (since no equal one will follow from then), e.g.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
size_t printAllEqual(const vector<StudentAttempt>& v, const StudentAttempt& sa, stringstream& ss ) {

  vector<StudentAttempt>::const_iterator i = v.begin();
  size_t sz = 0;
  bool bFirst = true;

  while (i != v.end()) {

    if(isDistEqual(*i,sa)) {
    
      if (!bFirst) ss << ',';
      ss << i->studentName;
      ++sz;

      // we can stop here when encountering distances
      // larger than the one we're since the vector is
      // sorted in ascending order (if not, this would cause errors)
      // Higher distances will never equal ours
      if (i->distance > sa.distance) break;
    }

    ++i; 
    bFirst = false;
  }

  return sz;
}
Random Solutions  
 
programming4us programming4us