473,413 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

error handling - a couple of questions:

I am writing error handling procedures at the moment. Here are some
questions:

1. Can you write a procedure that picks up any error and deals with it no
matter where it happens in the database?

2. Does Access keep a list of errors in a "secret" table?

3. Is there a way to handle common errors (such as - "you need to choose
from the list" or "a related record is required in ....") with just one
procedure that applies to all forms???
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.687 / Virus Database: 448 - Release Date: 16/05/2004
Nov 12 '05 #1
3 3059
In answer to 1 and 3, put your error code in a public sub in a standard module
and call it everywhere you need it.

In answer to 2, look at error codes in the Help file.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"WindAndWaves" <ac****@ngaru.com> wrote in message
news:R0*******************@news.xtra.co.nz...
I am writing error handling procedures at the moment. Here are some
questions:

1. Can you write a procedure that picks up any error and deals with it no
matter where it happens in the database?

2. Does Access keep a list of errors in a "secret" table?

3. Is there a way to handle common errors (such as - "you need to choose
from the list" or "a related record is required in ....") with just one
procedure that applies to all forms???
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.687 / Virus Database: 448 - Release Date: 16/05/2004

Nov 12 '05 #2
1. Generic error handler
Every Sub and Function must have its own error handling, but the procedure
can call a generic error handler to do the work.

For an example of a generic handler that logs errors to a table, see:
http://allenbrowne.com/ser-23a.html
For a free tool that drops the error handler into a procedure with one mouse
click, see:
http://www.mztools.com

You need to call another procedure in the Error event of your forms to catch
those errors also. These DataErr values are not easy to come by, but some
common ones are:
3022 duplicate index violation
3024 data file missing (e.g. network down).
3021 related record required
3314 field is marked Required, and no value supplied.
2113 invalid data type
2. Listing of error messages
You can get the internal errors from the AccessError method, e.g.:
? AccessError(2001)

There is a list of the JET errors in a file that depends on your version of
Access.
For A2003 it is JetErr40.chm, typically in:
\Program Files\Common Files\Microsoft Shared\OFFICE11\1033\
Create a shortcut to the file for quick access.
3. Common Errors
As described in #1 above, this is a matter of using error handling in all
procedures, and hooking the Error event of the form. Use a Select Case
statement to respond to the various errors, e.g.:
Select Case Err.Number
Case 3314, 2101, 2115
strMsg = "Record cannot be saved at this time." & vbCrLf & _
"Complete the entry, or press <Esc> to undo."
Case 0, 2501
'just ignore these.
Case Else
strMsg = Err.Description
End Select
If Len(strMsg) > 0 Then
MsgBox strMsg
End If

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"WindAndWaves" <ac****@ngaru.com> wrote in message
news:R0*******************@news.xtra.co.nz...
I am writing error handling procedures at the moment. Here are some
questions:

1. Can you write a procedure that picks up any error and deals with it no
matter where it happens in the database?

2. Does Access keep a list of errors in a "secret" table?

3. Is there a way to handle common errors (such as - "you need to choose
from the list" or "a related record is required in ....") with just one
procedure that applies to all forms???

Nov 12 '05 #3
Thanks Allen, those are great links.
---
Please immediately let us know (by phone or return email) if (a) this email
contains a virus
(b) you are not the intended recipient
(c) you consider this email to be spam.
We have done our utmost to make sure that
none of the above are applicable. THANK YOU
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.687 / Virus Database: 448 - Release Date: 16/05/2004
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: ale.of.ginger | last post by:
Greetings! I am trying to make a multiplayer (no AI, 2 person) game of tic tac toe in Python. So far it has been pretty simple. My only concern is with the win checking to see if a person has...
2
by: Steve Richfield | last post by:
My error handler works GREAT. However, VBA seems to have some bugs/features that are causing it fits. The little snippet that I put at the end of each routine looks like this: Error_Handler: If...
13
by: Thelma Lubkin | last post by:
I use code extensively; I probably overuse it. But I've been using error trapping very sparingly, and now I've been trapped by that. A form that works for me on the system I'm using, apparently...
4
by: aaj | last post by:
Hi all I have an automated application, that runs in the middle of the night. If certain 'non system' errors occur (things like malformed files, missing files etc..), I send an automatic Email...
6
by: José Joye | last post by:
Hello, I'm currently reading the MS Developing Web applications with c# (and VB.net). In the chapter related to Error management, there is a sample about "Page-Level Error Pages" eg: In my...
4
by: sm | last post by:
Hi, I have a couple of questions with regards to handling errors and exceptions. 1. If I use On Error goto Errhandler ... Errhandler:
6
by: miky | last post by:
Hi, I'm trying to get custom gridview paging working and I'm getting the following error: "ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'count' that has parameters:...
5
by: csgraham74 | last post by:
Hi guys, Basically i have been developing in dotnet for a couple of years but ive had a few issues in regards to error handling. For example - I have a class that i call passing in a stored...
1
by: pob | last post by:
>From a form I have some code that calls 4 modules frmMain 1 mod 2 mod 3 mod 4 mod If mod 1 experiences an error the error handling works fine within mod 1 and writes out the error to a...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.