AccessError and MsgBox formatting

Vivitech

Registered User.
Local time
Today, 08:36
Joined
May 11, 2004
Messages
18
Hi,

I've written a custom error handler in A2K which I want to call from Form_Error(). This is to trap Access (not VBA) errors when somebody does something silly that Access/JET objects to. In these cases Err is NOT set, so the only way to get the error description, as I understand it, is to call AccessError(iErrorNumber).

First problem: The message returned by AccessError() contains @ characters which used to be decoded by A97's MsgBox() function, but are printed literally in A2K, because it's implementation of MsgBox doesn't understand them.

I've implemented the solution advocated at

http://www.mvps.org/access/bugs/bugs0035.htm

and this does overcome the problem, partially, but it would be much more professional if I could use a custom form instead of MsgBox.

Is there a way of getting the decoded string back, rather than having to call Eval("MsgBox(.....") ??


Also, this does not solve the whole problem. Second (more important) problem:

For testing, I am deliberately trying to make a form add a record to a table which needs a related record in, say, tblAddressType. If I add a new record and try to close the form, this causes a 3201 error.

Without a Form_Error() routine, I get the default message box:

You cannot add or change a record because a related record is required in table 'tblAddressTypes'.

but if I define a Form_Error and call AccessError inside it, even after the Eval() fix above, I get:

You cannot add or change a record because a related record is required in table '|'.


Clearly the '|' is a marker for the name of the related table, but how do I get at it from within Form_Error()??

It seems to me that this is a glaring 5-year old bug which has never been addressed - what is the point in allowing users to intercept Access/JET errors with Form_Error() if you can't get at the error text?

Please, can anyone help?!
 

Users who are viewing this thread

Back
Top Bottom