By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,939 Members | 1,684 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,939 IT Pros & Developers. It's quick & easy.

how can i handle errors in access?

P: 115
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 :
Expand|Select|Wrap|Line Numbers
  2. Private Sub article_AfterUpdate()
  3. On Error GoTo Err_article_AfterUpdate
  5.     DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
  7. Exit_article_AfterUpdate:
  8.     Exit Sub
  10. Err_article_AfterUpdate:
  11.     'MsgBox Err.Description
  12.     MsgBox Prompt:="This article is already entered. Please choose another article number"
  14.     Resume Exit_article_AfterUpdate
  15. 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
Aug 3 '10 #1
Share this Question
Share on Google+
2 Replies

P: 393
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
just build your own little error form and base and if then statement on the result of that.
Aug 3 '10 #2

P: 115
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.
Aug 3 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.