473,654 Members | 3,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get actual text of error trapped by Form_Error?

TC
Folks

Is there >>ANY<< way to get the actual text of an error that is trapped by
the Form_Error event?

I mean actual text like: "duplicate record in table XYZ", not template text
like: "duplicate record in table |1".

I need this for a general purpose error handler. I've tried everything
obvious, including err.description , the dbengine.errors collection & so on.
I think the answer is NO. I would like to be proved wrong.

TIA,
TC


Nov 12 '05 #1
13 5471
DFS
TC,

In the Form_Error event, add this line:

MsgBox AccessError(Dat aErr)

and you'll be able to see the actual text - at least I could for run-time
errors 3022 (dupes) and 2169 (can't save record).


"TC" <a@b.c.d> wrote in message news:1071375900 .155857@teuthos ...
Folks

Is there >>ANY<< way to get the actual text of an error that is trapped by
the Form_Error event?

I mean actual text like: "duplicate record in table XYZ", not template text like: "duplicate record in table |1".

I need this for a general purpose error handler. I've tried everything
obvious, including err.description , the dbengine.errors collection & so on. I think the answer is NO. I would like to be proved wrong.

TIA,
TC

Nov 12 '05 #2
There is a way to do this, but it's really bizzare, and the technique cannot
be made to work flawlessly in Access 2000, only in 97 or 2002.

Basically, you have to intercept every attempt to save or delete a record
using BeforeUpdate or BeforeDeleteCon firm, perrform the action yourself on the
form's RecordsetClone, then cancel the event. Since the actual update happens
in VB code, you can capture the error there.

In order to perform the update in code, you have to loop through all the form
controls, and determine which ones have ControlSource properties, and have
them set to non-blank text that does not begin with the = Character, and copy
the data from the control values into the recordset field values.
Additionally, you have to make sure you don't copy any value that IsEmpty,
since those fields should receive their default values, and you must also make
sure the field in the recordset is updateable, not read-only.

Note that no techniques for determining the updateability of are 100% reliable
with ODBC linked tables, so you may have to use a tag property or something to
indicate non-updateable fields that are not properly reflected in the field
object properties.

Note that a partial solution can be found on MS Support in article 185384.
The don't say it's partial, but I found that you have to add a lot of special
case checks for any real-worls usage, and it doesn't cover the case of
deleting a record.

On Sun, 14 Dec 2003 14:55:24 +1200, "TC" <a@b.c.d> wrote:
Folks

Is there >>ANY<< way to get the actual text of an error that is trapped by
the Form_Error event?

I mean actual text like: "duplicate record in table XYZ", not template text
like: "duplicate record in table |1".

I need this for a general purpose error handler. I've tried everything
obvious, including err.description , the dbengine.errors collection & so on.
I think the answer is NO. I would like to be proved wrong.

TIA,
TC


Nov 12 '05 #3
That does work for error messages that do not have replaceable, case-specific
arguments, but does not work for error messages with replaceable arguments.
It also doesn't work for ODBC errors, so any ODBC error will simply say "ODBC
Error" - not very useful.

On Sat, 13 Dec 2003 23:49:20 -0500, "DFS" <no****@nospam. com> wrote:
TC,

In the Form_Error event, add this line:

MsgBox AccessError(Dat aErr)

and you'll be able to see the actual text - at least I could for run-time
errors 3022 (dupes) and 2169 (can't save record).


"TC" <a@b.c.d> wrote in message news:1071375900 .155857@teuthos ...
Folks

Is there >>ANY<< way to get the actual text of an error that is trapped by
the Form_Error event?

I mean actual text like: "duplicate record in table XYZ", not template

text
like: "duplicate record in table |1".

I need this for a general purpose error handler. I've tried everything
obvious, including err.description , the dbengine.errors collection & so

on.
I think the answer is NO. I would like to be proved wrong.

TIA,
TC


Nov 12 '05 #4
no****@nospam.n ospam (Steve Jorgensen) wrote in
<a3************ *************** *****@4ax.com>:
Basically, you have to intercept every attempt to save or delete a
record using BeforeUpdate or BeforeDeleteCon firm, perrform the
action yourself on the form's RecordsetClone, then cancel the
event. Since the actual update happens in VB code, you can
capture the error there.


Sounds like an unbound form would solve the problem, no?

But, of course, you'd have to code replacements for all the events
that unbound forms don't have.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #5
On Sun, 14 Dec 2003 20:54:23 GMT, dX********@bway .net.invalid (David W.
Fenton) wrote:
no****@nospam. nospam (Steve Jorgensen) wrote in
<a3*********** *************** ******@4ax.com> :
Basically, you have to intercept every attempt to save or delete a
record using BeforeUpdate or BeforeDeleteCon firm, perrform the
action yourself on the form's RecordsetClone, then cancel the
event. Since the actual update happens in VB code, you can
capture the error there.


Sounds like an unbound form would solve the problem, no?

But, of course, you'd have to code replacements for all the events
that unbound forms don't have.


The main problem with unbund forms is that they cannot be continuous, and I
find continuous forms too compelling to omit. Even if the main form could be
non-continuous, I almost always want some kind of editable, continuous
subform.
Nov 12 '05 #6
TC
Thanks for that, but it's the errors with "replaceabl e arguments" that I'm
on about. With those errors, the AccessError() messages contain placeholders
like |1, |2 etc. The actual messages (displayed at runtime) have explicit
names (of tables or whatever) in those positions. I need those explicit
names.

Thanks,
TC
"DFS" <no****@nospam. com> wrote in message
news:vt******** ****@corp.super news.com...
TC,

In the Form_Error event, add this line:

MsgBox AccessError(Dat aErr)

and you'll be able to see the actual text - at least I could for run-time
errors 3022 (dupes) and 2169 (can't save record).


"TC" <a@b.c.d> wrote in message news:1071375900 .155857@teuthos ...
Folks

Is there >>ANY<< way to get the actual text of an error that is trapped by the Form_Error event?

I mean actual text like: "duplicate record in table XYZ", not template

text
like: "duplicate record in table |1".

I need this for a general purpose error handler. I've tried everything
obvious, including err.description , the dbengine.errors collection & so

on.
I think the answer is NO. I would like to be proved wrong.

TIA,
TC


Nov 12 '05 #7
TC
Ok, thanks. That's a neat idea, that I will remember! But it would be
overkill for my current need.

I have a generic Form_Error handler that I can call from any form in any
application. It already handles various errors, such as, the 3 or 4
variations of "missing required field". For those errors, for example, it
just iterates the form controls, in tab order, looking for the first one
which is null (or ""), but bound to a mandatory field. Then it moves the
cursor to that control, & says "This value must be entered".

I wanted to enhance this handler with some extra errors. However, none of
the errors in question can be handled accurately, unless you know the actual
table(/whatever) names, from the runtime error message. That's why I need
the actual message. But it seems that it can not be done directly, from
within Form_Error :-(

Thanks for the suggestion,
TC
"Steve Jorgensen" <no****@nospam. nospam> wrote in message
news:a3******** *************** *********@4ax.c om...
There is a way to do this, but it's really bizzare, and the technique cannot be made to work flawlessly in Access 2000, only in 97 or 2002.

Basically, you have to intercept every attempt to save or delete a record
using BeforeUpdate or BeforeDeleteCon firm, perrform the action yourself on the form's RecordsetClone, then cancel the event. Since the actual update happens in VB code, you can capture the error there.

In order to perform the update in code, you have to loop through all the form controls, and determine which ones have ControlSource properties, and have
them set to non-blank text that does not begin with the = Character, and copy the data from the control values into the recordset field values.
Additionally, you have to make sure you don't copy any value that IsEmpty,
since those fields should receive their default values, and you must also make sure the field in the recordset is updateable, not read-only.

Note that no techniques for determining the updateability of are 100% reliable with ODBC linked tables, so you may have to use a tag property or something to indicate non-updateable fields that are not properly reflected in the field object properties.

Note that a partial solution can be found on MS Support in article 185384.
The don't say it's partial, but I found that you have to add a lot of special case checks for any real-worls usage, and it doesn't cover the case of
deleting a record.

On Sun, 14 Dec 2003 14:55:24 +1200, "TC" <a@b.c.d> wrote:
Folks

Is there >>ANY<< way to get the actual text of an error that is trapped bythe Form_Error event?

I mean actual text like: "duplicate record in table XYZ", not template textlike: "duplicate record in table |1".

I need this for a general purpose error handler. I've tried everything
obvious, including err.description , the dbengine.errors collection & so on.I think the answer is NO. I would like to be proved wrong.

TIA,
TC

Nov 12 '05 #8
On Sun, 14 Dec 2003 14:55:24 +1200, "TC" <a@b.c.d> wrote:

After seeing Steve's "solution", I would rather use the method I'm
typically using: forego the Form_Error handler altogether, and have
error handling in every procedure. This error handling is added by an
add-in we wrote, and calls a central error handling function (where we
typically suppress error 2501, etc).

-Tom.

Folks

Is there >>ANY<< way to get the actual text of an error that is trapped by
the Form_Error event?

I mean actual text like: "duplicate record in table XYZ", not template text
like: "duplicate record in table |1".

I need this for a general purpose error handler. I've tried everything
obvious, including err.description , the dbengine.errors collection & so on.
I think the answer is NO. I would like to be proved wrong.

TIA,
TC


Nov 12 '05 #9
There are some errors that will not be caught using your method, and
Form_Error is needed for them.
--
MichKa [MS]
NLS Collation/Locale/Keyboard Development
Globalization Infrastructure and Font Technologies

This posting is provided "AS IS" with
no warranties, and confers no rights.
"Tom van Stiphout" <to*****@no.spa m.cox.net> wrote in message
news:87******** *************** *********@4ax.c om...
On Sun, 14 Dec 2003 14:55:24 +1200, "TC" <a@b.c.d> wrote:

After seeing Steve's "solution", I would rather use the method I'm
typically using: forego the Form_Error handler altogether, and have
error handling in every procedure. This error handling is added by an
add-in we wrote, and calls a central error handling function (where we
typically suppress error 2501, etc).

-Tom.

Folks

Is there >>ANY<< way to get the actual text of an error that is trapped bythe Form_Error event?

I mean actual text like: "duplicate record in table XYZ", not template textlike: "duplicate record in table |1".

I need this for a general purpose error handler. I've tried everything
obvious, including err.description , the dbengine.errors collection & so on.I think the answer is NO. I would like to be proved wrong.

TIA,
TC

Nov 12 '05 #10

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

Similar topics

8
5154
by: swathky | last post by:
I've tried mutiple things but no go -- (sorry this is so long) I'm collecting a 5 digit number in an input box function and all works fine until a number is passed that doesn't exist in the database. I can't figure out where/how to check that the number exists before I get the error code 2105. Here's my function to get the number that I run when a command button is clicked to open the frmEditLoans form: Public Function...
9
10880
by: Robert Wing | last post by:
I support an MS Access application in which errors are trapped using the On Error statement. Just recently, the users of this system have experienced run-time error number 3021 on a random basis. My biggest problem right now is that the error description associated with this error is Application-defined or object-defined error. It has always been my understanding that these error numbers would not be used by Microsoft and were available...
14
10126
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought I should give back to the community by posting our findings. Thanks you all for all your help till now by posting problems and their solutions. ~Abhijit
5
2986
by: MLH | last post by:
I get error 3315 when attempting to enter ZLS into a text-type table field whose allow zls property is set to false. The error says "Field MyTable.MyField can't be a zero-length string" For sure, this is what I expected, entering into a table. The same 3315 error occurs if you try to enter "" into a bound textbox control on a form (bound to the same field. I expected that too.
6
4555
by: Matt | last post by:
Can anyone give me a good reason to use BOTH application scope Page_Error and the page scope Page_Error when trapping errors in a web application? Is there any real benefit to using the Page_Error if you are already capturing errors in Application_Error? Also, if you have any links to discussions about when to use which function it would be helpful.
14
2614
by: Dixie | last post by:
I am trying to write some code that when I exit my application kills all of the text files in a certain folder. It is possible that some of those files are locked because someone else is using them, in which case they will have the first two letters of their name replaced with ~$. How can I write a routine that will delete all the normal *.txt files, but not attempt to delete the ~$ ones, which brings up an error message and prevents the...
8
13095
by: g_man | last post by:
I am trying trap Runtime error 3022 (duplicates) in the click event of a command button that closes the form. I have code in the Form_Error event that does a good job of providing a more meaningful error message than the default. It works in every situation except when the user clicks the close button. I am using Me.Dirty=False to force a save but if there are duplicates I just get the standard Runtime 3022 error message. I am wondering...
7
22770
ADezii
by: ADezii | last post by:
One of the most frequently asked questions here at TheScripts is: Can I replace Standard Access Error Messages with my own? The answer is yes under certain circumstances and it involves the placement of code in a Form's Error() Event and setting a specific Parameter to either 1 of 2 values. Many Errors occur while your Form is active and it is within this context that you can replace the standard Access behavior when these Errors occur with...
0
1933
by: rclark30 | last post by:
Hello to everyone out there. I am a non SQL person TRAPPED in a nightmare! The long short is we have a CRM 3.0 database that is running in SQL 2005 on a Windows 2003 SP1 Server. (HP ProLiant ML350 3.0ghz 3.5gb RAM) Server started running out of drive space and could not hold transaction log. Would basically lock up everyones sessions until flushed. Put a cap on log size until drives could be purchased and installed. Perfomance suffered...
0
8375
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
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
8707
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8593
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...
1
6161
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
5622
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.