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

Modify System Error Messages

P: 2
I have a Form to which records are added using an Append Query which relies on a parameter entered by the user. In the event that the parameter supplied by user would cause a duplicate entry, the system generates an error message which would not make much sense to the average end user. I wish to customize my own message if this problem occurs. I have made some attempts to replace the system message by setting the Form's OnErrr property as follows:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2.    MsgBox "Error No.:" & DataErr
  4. If DataErr = 2950 Then
  5.     MsgBox "Employee ID # you supplied has already been entered.  Please enter your Employee ID #."
  7.     Response = acDataErrContinue
  9.     Else
  10.         MsgBox "Error No.:" & DataErr
  11. End If
  13. End Sub
This however has not solved the problem as I continue to get the system generated error. I wonder if it does not work because the error is as a result of the Query and not necessarily the Form?

Would really appreciate some help.
Thanks much.
Feb 2 '12 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 100+
P: 2,321
First off, are any of the custom message boxes you have shown here displayed? I.e. is the code actually being run?

You mention an append query, but don't show any code runnning said append query. Please supply those details.
Feb 2 '12 #2

P: 2
Thanks for your response,

No, the message boxes don't display. My queries are not written in VB codes but created in Access. I can however show you the SQL that Access generates for the query below:

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [Attendance 2] ( [Employee #], Employee, [Employee ID], [Department Name], [Late Exempt] )
  2. SELECT EMPLOYEES.[Employee #], [Fname] & " " & [Lname] AS Employee, EMPLOYEES.[Employee ID], Department.[Department Name], EMPLOYEES.[Late Exempt]
  3. FROM (EMPLOYEES LEFT JOIN Attendance ON EMPLOYEES.[Employee ID] = Attendance.[Employee ID]) LEFT JOIN Department ON EMPLOYEES.[Department ID] = Department.[Department ID]
  4. WHERE (((EMPLOYEES.[Employee #])=[Enter Your Employee # and click OK -  Check that your name appears at the bottom of list]));
Hopes this give you a little more insight into my problem.
Feb 2 '12 #3

Expert Mod 15k+
P: 31,492
This sounds like your code is not breaking on errors. See Debugging in VBA - 3) General Tips for help with this.
Feb 2 '12 #4

Post your reply

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