473,657 Members | 2,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3084
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******@pcdata sheet.com
www.pcdatasheet.com
"WindAndWav es" <ac****@ngaru.c om> wrote in message
news:R0******** ***********@new s.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(200 1)

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.

"WindAndWav es" <ac****@ngaru.c om> wrote in message
news:R0******** ***********@new s.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
2684
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 won. At first it looked like it was working, but now it sometimes assigns a win when you enter an X or O (doesn't matter) on certain tiles (row 1, column 1 won't be an error, but row 2, column 3 will be...). If you can find the problem, I'd be...
2
2370
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 Error_Handler("<routine name>", Err) = acDataErrDisplay Then On Error GoTo 0 Stop: Resume ' Press twice to view the problem.
13
4470
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 runs into problems on the system where it will actually be used, and since I used so little error-trapping it dies very ungracefully. I will of course try to fix whatever is causing the error and add error-trapping to the functions where the...
4
2521
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 and write a record to the database. This is handled in a class. When these errors occur, once Emailed and written I want to just end the App, simple as that.
6
4595
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 form: ========
4
1837
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
3947
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: p_TableName, p_OrderBy, p_MaxRows, p_PageNum, p_StartRowIndex." I have a gridview associated to an ObjectDataSource and the ObjectDataSource is declared in the aspx file as follows:
5
1732
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 procedure and connection string as a path. My method returns a dataset. In my SP i have an output parameter which tells me whether the SP select is successful or not. If i get a error code passed back then i throw an exception this then returns...
1
2249
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 table, but the other modules still get
0
8319
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8612
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7347
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2739
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.