Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2002
    Location
    TX
    Posts
    34

    Unanswered: suppress error messages

    How do you suppress Microsoft Access error messages?
    For instance, when user enters date format incorrectly I would like my own msgbox to appear instead of access. But I don't know how to suppress MS A2K's error msg.

    Any suggestions?

    Thanks

  2. #2
    Join Date
    Jan 2003
    Location
    Aberdeen, Scotland, UK
    Posts
    168
    on error resume next
    J.

  3. #3
    Join Date
    Apr 2002
    Location
    TX
    Posts
    34
    John,

    At which event do you suggest is the best place to put it?

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    try to get user entry mistakes before an error is noticed by Access: _beforeupdate is a good place to start, input masks help too.

    if on error is to help you display your own msg you need to be in code. some examples - maybe you have an update button that's going to post the user's edits somewhere:

    private sub update_click()

    on error goto err_update_click1
    'first part of your code which might trigger an error of somesort

    on error goto err_update_click2
    'second part of your code which might trigger an error of somesort

    on error goto err_update_click3
    'third part of your code which might trigger an error of somesort

    'etc for other error-risk areas of your code

    'your working code is above this line: rest is exit & error handling
    exit_update_click:
    'maybe some tidy-up code if you need it
    exit sub

    err_update_click1:
    msgbox "something went wrong in the first part"
    resume next 'will resume execution in line after error line

    err_update_click2:
    msgbox "something went wrong in the second part"
    'find a way to fix the error here, then
    resume 'will resume execution at the (now fixed) error line

    err_update_click3:
    msgbox "something went wrong in the third part"
    resume exit_update_click 'will resume execution at your exit sequence

    end sub

    choose which resume to use carefully: plain resume goes into an infinite loop if your fix doesn't work.

    izy

  5. #5
    Join Date
    Apr 2002
    Location
    TX
    Posts
    34
    Thanks, I'll try it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •