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

On Error Goto programming issue

P: 1
Hi,

I'm trying to error trap an append query, if the record already exists in the table. I'm not sure why the error message ("Rule already exisits") pops up regardless if that record is in the table or not. Any help would be much appreciated.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSubmit_Click():
  2.  
  3. On Error GoTo Proc_Err
  4.    DoCmd.OpenQuery ("QryAddBusinessRuleComment")
  5.  
  6. Proc_Err:
  7. MsgBox ("Rule already exisits!")
  8.  
  9. End Sub
  10.  
Oct 11 '07 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,315
Hi,

I'm trying to error trap an append query, if the record already exists in the table. I'm not sure why the error message ("Rule already exisits") pops up regardless if that record is in the table or not. Any help would be much appreciated.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSubmit_Click():
  2.  
  3. On Error GoTo Proc_Err
  4.    DoCmd.OpenQuery ("QryAddBusinessRuleComment")
  5.  
  6. Proc_Err:
  7. MsgBox ("Rule already exisits!")
  8.  
  9. End Sub
  10.  
The On Error tells Access to go to a Label when there's an error. It does not tell it to skip the label.
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSubmit_Click():
  2.  
  3. On Error GoTo Proc_Err
  4.    DoCmd.OpenQuery ("QryAddBusinessRuleComment")
  5.    Exit Sub
  6.  
  7. Proc_Err:
  8. MsgBox ("Rule already exisits!")
  9.  
  10. End Sub
  11.  
Oct 11 '07 #2

Post your reply

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