how can i handle errors in access?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hannoudw
    New Member
    • Aug 2010
    • 115

    how can i handle errors in access?

    i had built a form to add orders , and while adding orders i specify the article number of the item and the quantity and in that way i'm adding items to my stock.
    In that form i have a primary key (article number).
    so if i tried to add another article with the same article number an prompt error form the access is popping up.
    i wanted to write my own alert message !
    so i wrote this :
    Code:
    Private Sub article_AfterUpdate()
    On Error GoTo Err_article_AfterUpdate
    
        DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
    
    Exit_article_AfterUpdate:
        Exit Sub
    
    Err_article_AfterUpdate:
        'MsgBox Err.Description
        MsgBox Prompt:="This article is already entered. Please choose another article number"
        
        Resume Exit_article_AfterUpdate
    End Sub
    that works fine , the prompt message pop up and when i click ok and i changed the article number to a valid on it works.
    but the question : what if i changed my mind and i don't wanna add anymore articles to the order??! the error still and i need to close the form and reopened it again ! any help please
  • dsatino
    Contributor
    • May 2010
    • 393

    #2
    I didn't follow you completely, but I think I got the general idea. Basically you need to either select a built in msgbox with two buttons and base and if/then statement on the result of the button pushed
    or
    just build your own little error form and base and if then statement on the result of that.

    Comment

    • hannoudw
      New Member
      • Aug 2010
      • 115

      #3
      i just want when the prompt message from the msgbox pop up and i press ok. that error to go away . like i didn't insert the article at the first place. can this be done with msgbox or in anything else. help please.

      Comment

      Working...