你试试看下面的行么?
 on error goto ERRdata
   ……
   ……
 ERRdata:
    msgbox("……")
    exit sub

解决方案 »

  1.   

    on Error goto Proc_Err
    .....
    ........
    ......Proc_Err:
       ShowError "frmlogin", "CmdOK", Err.Num, Err.Description
    '*错误处理模块
    Public Sub ShowError(strModule As String, strProcedure As String, lngErrorNUmber As Long, _
                         strErrorDescription As String)
    On Error GoTo Proc_Err
    Dim strMessage As String '错误信息
    Dim strCaption As String '提示框标题
    Dim intLogFile As Integer '错误日志文件   intLogFile = FreeFile
       
       Open "errreport.txt" For Append As #intLogFile
       
       Print #intLogFile, "****** 错误发生时间-" & VBA.Now & " ******"
       Print #intLogFile, "错误号:" & lngErrorNUmber
       Print #intLogFile, "错误描述:" & strErrorDescription
       Print #intLogFile, "过程名:" & strProcedure
       Print #intLogFile, "模块名:" & strModule
       
       Print #intLogFile, ""
       
       Close #intLogFile
       
       strMessage = "Error:" & strErrorDescription & vbCrLf & vbCrLf & _
                    "Module:" & strModule & vbCrLf & _
                    "Procedure:" & strProcedure
        
        strCaption = "Unexpect Error! Version: " & _
                    Str$(App.Major) & "." & Str$(App.Minor) & "." & _
                    Format(App.Revision, "0000")
                    
        MsgBox strMessage, vbCritical, strCaption
        
    Proc_Exit:
        
        Exit Sub
        
    Proc_Err:
        
        Resume Next
        
    End Sub
      

  2.   

    既然是自动错误处理就不要用msgbox弹出这种模式对话框了,根据错误号和源多做处理吧
      

  3.   

    Try Catch
                   
     End Try
      

  4.   

    Try   Catch e As Exception  FinallyEnd Try
    #######################################################################################                       曾记否,蓝天上的那朵白云
                          慢慢的,不知不觉的飘走了
    -------------------------------------------------------------------