Senin, 30 Juli 2018

[MS_AccessPros] Re: Error Trapping for a Append Query

 

Jim - When an action query is cancelled it generates Err 2501 so you can capture the error this way:


Public Function Test_code() As String
    Dim strQuery As String
    

    On Error GoTo err_PROC

    strQuery = "Employees Query1"
    DoCmd.OpenQuery strQuery
    MsgBox "Process completed", vbInformation

exit_PROC:
    On Error Resume Next
    Exit Function

err_PROC:
    Dim strErrMsg As String
    Dim lngIcon As Long
    
    Select Case Err.Number
        Case 2501
            'Open cancelled.
            strErrMsg = "Action Cancelled."
            lngIcon = vbOKOnly + vbInformation
        Case Else
            strErrMsg = Err.Description
    End Select

    If strErrMsg <> "" Then MsgBox strErrMsg, lngIcon, _
        "Error!"
    
    Resume exit_PROC
    
End Function

Regards,
Bill Mosca, Founder - MS_Access_Professionals
http://www.thatlldoit.com
My nothing-to-do-with-Access blog
http://wrmosca.wordpress.com



---In MS_Access_Professionals@yahoogroups.com, <luvmymelody@yahoo.com> wrote :

Hello all,


I have an append query being run from a button on a form. The user wants to see the Warnings pop up for the append query. But if she clicks NO to run the append query, the Message box appears stating that the process has run. How would I trap that error and not get a message box that states that a process was run when it really was not?


Right now it is in a macro which it will be moved to VBA.


the macro goes like this


SaveObject


qry_AppendVacancyRecordToTrackingComplete


message box "The Process has completed"


Thank You


Jim Wagner

__._,_.___

Posted by: wrmosca@comcast.net
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


SPONSORED LINKS
.

__,_._,___

Tidak ada komentar:

Posting Komentar