title: VB6 Exception Handling within the calling procedure
body: <p>I have two procedures procA and procB. procA is calling procB. An exception occurs within procB. I can handle the exception within procB, but i like to handle it within procA and this is what i did not get to work. I'm not very familiar with VB6 but i think this should be possible because MSDN says: </p>
  
  <blockquote>
    <p>If an error occurs while an error handler is active (between the occurrence of the error and a Resume, Exit Sub, Exit Function, or Exit Property statement), the current procedure's error handler can't handle the error. Control returns to the calling procedure. If the calling procedure has an enabled error handler, it is activated to handle the error.</p>
  </blockquote>
  
  <p>What i'm doing wrong?</p>
  
  <p>Now the code fragments:</p>
  
  <pre><code>Private Sub procA()
    On Error GoTo ErrHnd
    ...
    procB obj
    Exit Sub
  ErrHnd:
    MsgBox Err.Description, vbInformation, Me.caption
  End Sub
  
  Public Sub procB(ByRef rec As Object)
    On Error GoTo ErrHnd
    ... Exception occurs within DAO Recordset Operation
    Exit Sub
  ErrHnd:
    Select Case Err.Number
    Case 3022
      Err.Raise vbObjectError + 9999, Err.Source, "Error Text"
    Case Else
      ...
    End Select
  End Sub
  </code></pre>
  
  <p>I also tried to turn off exception handling within procB (On Error Goto 0) but it seems that procA never gets the Exception.</p>
  
  <p>Thanks for your help.</p>
  
  <p><strong>Edit:</strong> Additional information:</p>
  
  <ul>
  <li>Exception Raised from DAO.Recordset Object.</li>
  <li>I also tried to completele remove exception handling within procB with no effect.</li>
  <li>procA exists in another file then procB (data.cls, frmListArtikel.frm).</li>
  </ul>
  
  <p><strong>Solution:</strong> I didn't know that it makes a difference how the programm is executed. If i start it from the IDE, the Exception does not get handled by procA. If i start the EXE (previously making it from the IDE) from the Explorer, the Exception gets handled as desired by procA.</p>