Results 1 to 6 of 6

Error Handler

  1. #1
    Torinjr is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    53

    Error Handler

    Hi there,



    Im running the macro builder in an entry form for the on click save button.
    I want the macro to save the record and close form however on error it will display the macro error message box.
    Just struggling with the go to function as i really need a go to next next. Is there an easy way of doing this?

    Click image for larger version. 

Name:	macro.PNG 
Views:	13 
Size:	10.5 KB 
ID:	33992

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    45,160
    I don't use macros but does this help: https://support.office.com/en-us/art...1-CE9289D81913
    The GoTo goes to a submacro.

    Consider converting code to VBA.
    To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression. Attachment Manager is below Advanced editor window, click Go Advanced below Quick Reply window.

  3. #3
    Torinjr is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    53
    Thanks I think VBA would be the way to go and call upon an Errorhandler.
    However as Im not experienced with VBA could you please show me an example of code that would do the same as the IF MAcroError<>0 above that I can call upon?

    Thanks

  4. #4
    ridders52's Avatar
    ridders52 is offline Voodoo Is Practised
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    2,400
    Something like this - replace YourProcedureName with whatever yours is called

    Code:
    Private Sub YourProcedureName()
    
    On Error GoTo Err_Handler
    
       'all your code goes here
        
    Exit_Handler:
        Exit Sub
        
    Err_Handler:
        MsgBox "Error " & Err.Number & " in YourProcedureName procedure : " & vbCrLf & Err.description, vbCritical, "Program error"
        Resume Exit_Handler
    
    End Sub
    Colin (Mendip Data Systems), Website, email
    If this has helped, please click the star button and leave a comment

  5. #5
    Torinjr is offline Advanced Beginner
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    53
    Beauty Thank You

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    45,160
    To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression. Attachment Manager is below Advanced editor window, click Go Advanced below Quick Reply window.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Clean up screen after Error Handler finishes.
    By Phred in forum Programming
    Replies: 2
    Last Post: 02-11-2015, 12:41 PM
  2. error handler help
    By baronqueefington in forum Programming
    Replies: 3
    Last Post: 01-23-2015, 01:11 PM
  3. Need help with Error Handler
    By RingoStarr in forum Programming
    Replies: 5
    Last Post: 09-20-2013, 01:07 PM
  4. Simple Error Handler
    By Tim777 in forum Access
    Replies: 7
    Last Post: 11-16-2012, 05:23 PM
  5. Global Error Handler Issue
    By usmcgrunt in forum Programming
    Replies: 1
    Last Post: 11-02-2011, 07:26 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums