ProcessingTimeout Event Example

The example uses the ProcessingTimeout event to notify the user when an asynchronous operation has taken longer than expected.

Private Sub DataReport1_ProcessingTimeout(Seconds As Long, _
Cancel As Boolean, JobType As AsyncTypeConstants, Cookie As Long)
   ' Use a function to return a string that describes the job type.
   ' At set intervals, prompt the user to continue or cancel.
   Dim strJob As String
   strJob = GetJobType(JobType)
   Select Case Seconds
   Case 60
      If MsgBox("The " & strJob & " has taken " & Seconds & " seconds." _ 
      & " Do you want to cancel?", vbRetryCancel) = vbCancel Then _
      Cancel = True
   Case 90
      If MsgBox("The " & strJob & " has taken " & Seconds & " seconds." _ 
      & " Do you want to cancel?", vbRetryCancel) = vbCancel Then _
      Cancel = True
   Case 120
      ' Cancel the operation.
      Cancel = True
   End Select
End Sub

Private Function GetJobType(jType As AsyncTypeConstants) As String
   'Return the job type as a string.
   Select Case jType
   Case rptAsyncPreview
      GetJobType = "preview operation"
   Case rptAsyncPrint
      GetJobType = "print operation"
   Case rptAsyncExport
      GetJobType = "export report operation"
   Case Else
      'Handle other cases here.
   End Select
End Function