Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    98

    Unanswered: How to get rid of error messages?

    Well, the title explains it all I think... I get error messages when, for instance, I get to the end of a recordset and click on the 'next' button again. THen I get another message explaining the error message. I don;t want to see these second error messages so if anyone has an idea as to what I can do then that would be more than great!

  2. #2
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    421
    Try trapping the error using the On Error command

    Try looking "On Error" up in the Access help and see if you can figure it from there, come back with specific questions if you have em.

    Regards

  3. #3
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    98
    hi,

    Thanks for your help already! What I get from access help is that code can be written for specific error messages, etc. That is not what I am looking for though. I get two error messages (one after another). I think there must be a way to somewhere say that this second set of messages is unwanted, but I don't know where and how.

    I copied the messages. Please have a look and see if you know what I am doing wrong here?
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    421
    Hey, groetjes uit Amsterdam

    But lets keep it English for other viewers.

    Your using a macro in a button (am i correct) if you are DONT. Use VBA instead.

    Right click your button. Go to the properties sheet.
    Go to the on click event and change that to: [Event Procedure]
    Now click on the (dots) button next to that.

    You are now in the Module window.
    Presuming the button is called GaNaarVolgend (GoToNext for english viewers) it should look something like below, assuming there is no other code in the form that is....
    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub GaNaarVolgend_Click()
        
    End Sub
    Now paste below code between the private and End lines
    Code:
    On Error GoTo Err_GaNaarVolgend_Click
    
    
        DoCmd.GoToRecord , , acNext 'replace this acNext by acPrevious to go the other way
    
    Exit_GaNaarVolgend_Click:
        Exit Sub
    
    Err_GaNaarVolgend_Click:
        MsgBox Err.Description 'You can put your own message here if you want to.
        Resume Exit_GaNaarVolgend_Click
    That should do the trick

    Regards

  5. #5
    Join Date
    Jan 2004
    Posts
    1
    Private Sub bntName_Click()

    'SetWarnings to False in your button On Click event to suppress system messages

    DoCmd.SetWarnings False

    DoCmd.GoToRecord , , acNext

    Exit_btnName_Click:
    Exit Sub

    End Sub

  6. #6
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    421
    Dont use setwarnings false .... Geezzzz Halfway solution for just about everything.

    for 1 thing: You forgot resetting it!!!! => Docmd.setwarnings True
    Which is a bad thing to add to above statement.

    AND the exit button thing is not needed in this situation....

    I dont want to be a mr KnowItAll but take it from me, dont go there. Use the error trap as provided by me. (you can leave out the msgbox all together if you want.)

    Regards

  7. #7
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    98

    More questions...

    Heel erg bedankt! I'm going to try it out straight away. Just to get it straight: does this mean I have to paste this statement in every form that I have, for every event that I have placed? And if so, what do I do with button's that are generated via macro's?

    Thanks again for the help.

  8. #8
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    421
    Use macros as little as possible! They cause things like this and are hopelessly inflexible. Use VBA unless there is absolutly no other way (like for instance a Autoexec)

    You can create buttons like this using the wizard. It even creates the VBA (where i stole it from btw)
    You should indeed replace every OnClick event off every button like this one you have created if you wish to prevent this problem.

    Regards

    The Mailman

  9. #9
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    98
    Ok, thankyou very much for your help. I really appreciate 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
  •