Results 1 to 6 of 6
  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
    52,815
    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.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  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
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    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, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  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
    52,815
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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, 01:41 PM
  2. error handler help
    By baronqueefington in forum Programming
    Replies: 3
    Last Post: 01-23-2015, 02:11 PM
  3. Need help with Error Handler
    By RingoStarr in forum Programming
    Replies: 5
    Last Post: 09-20-2013, 02:07 PM
  4. Simple Error Handler
    By Tim777 in forum Access
    Replies: 7
    Last Post: 11-16-2012, 06:23 PM
  5. Global Error Handler Issue
    By usmcgrunt in forum Programming
    Replies: 1
    Last Post: 11-02-2011, 08: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
  •  
Other Forums: Microsoft Office Forums