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

Custom Erorr Message?

P: 1
Hi Everyone
i have a table with tow column "Err Number" And "Custom Message"
now! Please help me that how can i use the onErorr event to change the default message with my "Custom Message" by using this table.
i now that i can use this metode for one message.
Expand|Select|Wrap|Line Numbers
  1. if DataErr = 0000 then
  2.  msgbox  "xxxxxxxxxx"
  3. Response=acDataErrContinue
  4. end if
  5.  
but for all Erorr i have to Write all Message but by using this table i think that i can solve this Problem So Please Help Me.Sorry for my poor english
Regards.
[email removed]
Mar 18 '07 #1
Share this Question
Share on Google+
3 Replies


missinglinq
Expert 2.5K+
P: 3,532
Assuming the following:
Custom Message Table name = CustomErrorTable
Custom Message field = ErrorDescription
Error Number field = ErrorNumber

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2.   CustomMessage = DLookup("[ErrorDescription]", "CustomErrorTable", "[ErrorNumber] =" & DataErr)
  3.   resp = MsgBox(CustomMessage, vbExclamation)
  4.   Response = acDataErrContinue
  5. End Sub
  6.  
If you go to copy and paste the code, don't forget to scroll and get the hidden part of the code!
Mar 19 '07 #2

missinglinq
Expert 2.5K+
P: 3,532
Note that the above code is dependent on CustomErrorTable having a comprehensive list of error codes! I used such a table and then changed the messages for the errors I was concerned with!
Mar 19 '07 #3

missinglinq
Expert 2.5K+
P: 3,532
To avoid having to use a comprehensive list of error codes, I've modified the above code (added the bolded code) so that an error code not listed in your custom error table will be handled by Access' own error message.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2. If DCount("[ErrorNumber]", "CustomErrorTable", "[ErrorNumber] =" & DataErr) > 0 Then
  3. CustomMessage = DLookup("[ErrorDescription]", "CustomErrorTable", "[ErrorNumber] =" & DataErr)
  4. resp = MsgBox(CustomMessage, vbExclamation)
  5. Response = acDataErrContinue
  6. End If
  7. End Sub
Mar 19 '07 #4

Post your reply

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