Random error Message box

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

    #1

    Random error Message box

    hello,

    I have used the advice on this site to clear a specific error when a
    report is generated without any data.

    Err_cmdLaunchIt emsReport_Click :
    Select Case Err.Number
    Case 2501
    Err.Clear
    Case Else
    MsgBox Err.Number & Err.Description
    End Select

    However, if the report does have data, I now get a Message Box that has
    no heading and only contains a zero, "0". This happens everytime the
    report is opened.

    What have I done wrong/have I not done?

    Really appreciate your help.

  • Allen Browne

    #2
    Re: Random error Message box

    Above the code you posted, you forgot to add the line:
    Exit Sub
    or possibly:
    Exit Function

    As a result, even with the code runs successfully, the error handling part
    is executed too.

    --
    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.

    "badboybrow n" <seabrow@gmail. com> wrote in message
    news:1139831118 .664422.98230@z 14g2000cwz.goog legroups.com...[color=blue]
    > hello,
    >
    > I have used the advice on this site to clear a specific error when a
    > report is generated without any data.
    >
    > Err_cmdLaunchIt emsReport_Click :
    > Select Case Err.Number
    > Case 2501
    > Err.Clear
    > Case Else
    > MsgBox Err.Number & Err.Description
    > End Select
    >
    > However, if the report does have data, I now get a Message Box that has
    > no heading and only contains a zero, "0". This happens everytime the
    > report is opened.
    >
    > What have I done wrong/have I not done?
    >
    > Really appreciate your help.
    >[/color]


    Comment

    • Keith Wilby

      #3
      Re: Random error Message box

      "badboybrow n" <seabrow@gmail. com> wrote in message
      news:1139831118 .664422.98230@z 14g2000cwz.goog legroups.com...[color=blue]
      > hello,
      >
      > I have used the advice on this site to clear a specific error when a
      > report is generated without any data.
      >
      > Err_cmdLaunchIt emsReport_Click :
      > Select Case Err.Number
      > Case 2501
      > Err.Clear
      > Case Else
      > MsgBox Err.Number & Err.Description
      > End Select
      >
      > However, if the report does have data, I now get a Message Box that has
      > no heading and only contains a zero, "0". This happens everytime the
      > report is opened.
      >
      > What have I done wrong/have I not done?
      >
      > Really appreciate your help.
      >[/color]
      The zero is the contents of Err.Number - there is no error but the code is
      running anyway. You need "Exit Sub" before the error handling code.

      Keith.



      Comment

      • badboybrown

        #4
        Re: Random error Message box

        Thanks.

        Very much appreciated.

        I'm learning as I go...

        Comment

        Working...