Get actual text of error trapped by Form_Error?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TC

    Get actual text of error trapped by Form_Error?

    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




  • DFS

    #2
    Re: Get actual text of error trapped by Form_Error?

    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 ...[color=blue]
    > 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[/color]
    text[color=blue]
    > 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[/color]
    on.[color=blue]
    > I think the answer is NO. I would like to be proved wrong.
    >
    > TIA,
    > TC
    >
    >
    >
    >[/color]


    Comment

    • Steve Jorgensen

      #3
      Re: Get actual text of error trapped by Form_Error?

      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:
      [color=blue]
      >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
      >
      >
      >[/color]

      Comment

      • Steve Jorgensen

        #4
        Re: Get actual text of error trapped by Form_Error?

        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" <nospam@nospam. com> wrote:
        [color=blue]
        >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 ...[color=green]
        >> 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[/color]
        >text[color=green]
        >> 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[/color]
        >on.[color=green]
        >> I think the answer is NO. I would like to be proved wrong.
        >>
        >> TIA,
        >> TC
        >>
        >>
        >>
        >>[/color]
        >[/color]

        Comment

        • David W. Fenton

          #5
          Re: Get actual text of error trapped by Form_Error?

          nospam@nospam.n ospam (Steve Jorgensen) wrote in
          <a3rntvsuju4v0h 36q9ka34mu16p01 vd4i5@4ax.com>:
          [color=blue]
          >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.[/color]

          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

          Comment

          • Steve Jorgensen

            #6
            Re: Get actual text of error trapped by Form_Error?

            On Sun, 14 Dec 2003 20:54:23 GMT, dXXXfenton@bway .net.invalid (David W.
            Fenton) wrote:
            [color=blue]
            >nospam@nospam. nospam (Steve Jorgensen) wrote in
            ><a3rntvsuju4v0 h36q9ka34mu16p0 1vd4i5@4ax.com> :
            >[color=green]
            >>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.[/color]
            >
            >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.[/color]

            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.

            Comment

            • TC

              #7
              Re: Get actual text of error trapped by Form_Error?

              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" <nospam@nospam. com> wrote in message
              news:vtnqvsb1v4 ih19@corp.super news.com...[color=blue]
              > 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 ...[color=green]
              > > Folks
              > >
              > > Is there >>ANY<< way to get the actual text of an error that is trapped[/color][/color]
              by[color=blue][color=green]
              > > the Form_Error event?
              > >
              > > I mean actual text like: "duplicate record in table XYZ", not template[/color]
              > text[color=green]
              > > 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[/color]
              > on.[color=green]
              > > I think the answer is NO. I would like to be proved wrong.
              > >
              > > TIA,
              > > TC
              > >
              > >
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • TC

                #8
                Re: Get actual text of error trapped by Form_Error?

                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" <nospam@nospam. nospam> wrote in message
                news:a3rntvsuju 4v0h36q9ka34mu1 6p01vd4i5@4ax.c om...[color=blue]
                > There is a way to do this, but it's really bizzare, and the technique[/color]
                cannot[color=blue]
                > 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[/color]
                the[color=blue]
                > form's RecordsetClone, then cancel the event. Since the actual update[/color]
                happens[color=blue]
                > in VB code, you can capture the error there.
                >
                > In order to perform the update in code, you have to loop through all the[/color]
                form[color=blue]
                > controls, and determine which ones have ControlSource properties, and have
                > them set to non-blank text that does not begin with the = Character, and[/color]
                copy[color=blue]
                > 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[/color]
                make[color=blue]
                > sure the field in the recordset is updateable, not read-only.
                >
                > Note that no techniques for determining the updateability of are 100%[/color]
                reliable[color=blue]
                > with ODBC linked tables, so you may have to use a tag property or[/color]
                something to[color=blue]
                > indicate non-updateable fields that are not properly reflected in the[/color]
                field[color=blue]
                > 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[/color]
                special[color=blue]
                > 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:
                >[color=green]
                > >Folks
                > >
                > >Is there >>ANY<< way to get the actual text of an error that is trapped[/color][/color]
                by[color=blue][color=green]
                > >the Form_Error event?
                > >
                > >I mean actual text like: "duplicate record in table XYZ", not template[/color][/color]
                text[color=blue][color=green]
                > >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[/color][/color]
                on.[color=blue][color=green]
                > >I think the answer is NO. I would like to be proved wrong.
                > >
                > >TIA,
                > >TC
                > >
                > >
                > >[/color]
                >[/color]


                Comment

                • Tom van Stiphout

                  #9
                  Re: Get actual text of error trapped by Form_Error?

                  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.

                  [color=blue]
                  >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
                  >
                  >
                  >[/color]

                  Comment

                  • Michael \(michka\) Kaplan [MS]

                    #10
                    Re: Get actual text of error trapped by Form_Error?

                    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" <tom7744@no.spa m.cox.net> wrote in message
                    news:87vptvsb14 7jltrjn6qkjvm0c 65gcuau1e@4ax.c om...[color=blue]
                    > 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.
                    >
                    >[color=green]
                    > >Folks
                    > >
                    > >Is there >>ANY<< way to get the actual text of an error that is trapped[/color][/color]
                    by[color=blue][color=green]
                    > >the Form_Error event?
                    > >
                    > >I mean actual text like: "duplicate record in table XYZ", not template[/color][/color]
                    text[color=blue][color=green]
                    > >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[/color][/color]
                    on.[color=blue][color=green]
                    > >I think the answer is NO. I would like to be proved wrong.
                    > >
                    > >TIA,
                    > >TC
                    > >
                    > >
                    > >[/color]
                    >[/color]


                    Comment

                    • TC

                      #11
                      Re: Get actual text of error trapped by Form_Error?

                      I don't see how that helps. If you are not using Form_Error - and you are
                      not using a solution like Steve's - then you will get the default Access
                      error messages for the errors that would otherwise fire Form_Error. (I don't
                      see how error handlers anywhere, would trap those errors, in the absemce of
                      a solution like Steve's.) The point of my exercise is to replace those
                      standard errors - many of which are very confusing to the end-user.

                      Cheers,
                      TC


                      "Tom van Stiphout" <tom7744@no.spa m.cox.net> wrote in message
                      news:87vptvsb14 7jltrjn6qkjvm0c 65gcuau1e@4ax.c om...[color=blue]
                      > 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.
                      >
                      >[color=green]
                      > >Folks
                      > >
                      > >Is there >>ANY<< way to get the actual text of an error that is trapped[/color][/color]
                      by[color=blue][color=green]
                      > >the Form_Error event?
                      > >
                      > >I mean actual text like: "duplicate record in table XYZ", not template[/color][/color]
                      text[color=blue][color=green]
                      > >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[/color][/color]
                      on.[color=blue][color=green]
                      > >I think the answer is NO. I would like to be proved wrong.
                      > >
                      > >TIA,
                      > >TC
                      > >
                      > >
                      > >[/color]
                      >[/color]


                      Comment

                      • Tom van Stiphout

                        #12
                        Re: Get actual text of error trapped by Form_Error?

                        On Mon, 15 Dec 2003 10:57:45 +1200, "TC" <a@b.c.d> wrote:

                        Sorry, I was too quick to pull the trigger. You are correct; bound
                        forms can generate certain events only Form_Error can trap. It would
                        be nice if MSFT would expose more information to us developers. You
                        would think after 8 versions they might have gotten around to it...

                        -Tom.



                        [color=blue]
                        >I don't see how that helps. If you are not using Form_Error - and you are
                        >not using a solution like Steve's - then you will get the default Access
                        >error messages for the errors that would otherwise fire Form_Error. (I don't
                        >see how error handlers anywhere, would trap those errors, in the absemce of
                        >a solution like Steve's.) The point of my exercise is to replace those
                        >standard errors - many of which are very confusing to the end-user.
                        >
                        >Cheers,
                        >TC
                        >
                        >
                        >"Tom van Stiphout" <tom7744@no.spa m.cox.net> wrote in message
                        >news:87vptvsb1 47jltrjn6qkjvm0 c65gcuau1e@4ax. com...[color=green]
                        >> 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.
                        >>
                        >>[color=darkred]
                        >> >Folks
                        >> >
                        >> >Is there >>ANY<< way to get the actual text of an error that is trapped[/color][/color]
                        >by[color=green][color=darkred]
                        >> >the Form_Error event?
                        >> >
                        >> >I mean actual text like: "duplicate record in table XYZ", not template[/color][/color]
                        >text[color=green][color=darkred]
                        >> >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[/color][/color]
                        >on.[color=green][color=darkred]
                        >> >I think the answer is NO. I would like to be proved wrong.
                        >> >
                        >> >TIA,
                        >> >TC
                        >> >
                        >> >
                        >> >[/color]
                        >>[/color]
                        >[/color]

                        Comment

                        • TC

                          #13
                          Re: Get actual text of error trapped by Form_Error?


                          "Tom van Stiphout" <tom7744@no.spa m.cox.net> wrote in message
                          news:731qtvsbm3 qu9r0o3iqm1no9c ngofqorgt@4ax.c om...[color=blue]
                          > On Mon, 15 Dec 2003 10:57:45 +1200, "TC" <a@b.c.d> wrote:
                          >
                          > Sorry, I was too quick to pull the trigger. You are correct; bound
                          > forms can generate certain events only Form_Error can trap. It would
                          > be nice if MSFT would expose more information to us developers. You
                          > would think after 8 versions they might have gotten around to it...[/color]

                          (snip)

                          The flip side to that, is this: how come developers have accepted the crummy
                          default messages for so long? One of the most common user errors (missing
                          required field) comes in several versions that will surely confuse the user.
                          Don't we all have users saying, "WTF does >that< message mean?"

                          TC
                          (off for the day)



                          Comment

                          • Tom van Stiphout

                            #14
                            Re: Get actual text of error trapped by Form_Error?

                            On Mon, 15 Dec 2003 11:29:57 +1200, "TC" <a@b.c.d> wrote:

                            I agree. Perhaps we are too complacent.

                            One idea is to start a "I wish MSFT would get around to fixing this
                            problem" list. If it is in a well-traveled location (our official CDMA
                            site comes to mind - but I wouldn't presume to claim space on it), and
                            if it were quick to respond to new (beta) versions, perhaps MSFT would
                            take notice. Perhaps journalists writing glowing articles about the
                            next version of Access would take notice.
                            Contributions would be sent into a central location, perhaps this
                            newsgroup, and only be added to the list upon recommendation of
                            several people (to avoid "Function Left$ not found" entries).

                            I floated a trial balloon along these lines a year or more ago
                            (related to performance testing). No takers at that time. I'm floating
                            another one now.

                            -Tom.


                            [color=blue]
                            >
                            >"Tom van Stiphout" <tom7744@no.spa m.cox.net> wrote in message
                            >news:731qtvsbm 3qu9r0o3iqm1no9 cngofqorgt@4ax. com...[color=green]
                            >> On Mon, 15 Dec 2003 10:57:45 +1200, "TC" <a@b.c.d> wrote:
                            >>
                            >> Sorry, I was too quick to pull the trigger. You are correct; bound
                            >> forms can generate certain events only Form_Error can trap. It would
                            >> be nice if MSFT would expose more information to us developers. You
                            >> would think after 8 versions they might have gotten around to it...[/color]
                            >
                            >(snip)
                            >
                            >The flip side to that, is this: how come developers have accepted the crummy
                            >default messages for so long? One of the most common user errors (missing
                            >required field) comes in several versions that will surely confuse the user.
                            >Don't we all have users saying, "WTF does >that< message mean?"
                            >
                            >TC
                            >(off for the day)
                            >
                            >[/color]

                            Comment

                            Working...