How to not show vba error messages?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ryno Bower
    New Member
    • Nov 2010
    • 76

    #1

    How to not show vba error messages?

    Hi,

    I have a form with a cmdbutton on it called btnDelete.

    If i click on that button it will delete the current record. But then i get the message saying that you are about to delet 1 record....yes/no. Instead of that message I would like a msgbox to appear askin if you are sure to delete the record. If you click yes it deletes the record otherwise it does not delete it.

    I have searched on the internet but I dont seem to find a clear answer. COuld someon please help.

    Thanks
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    Hi Ryno

    The message your getting is a warning, not an error message. You can turn off warnings through code, but should always remember to turn them back on again. It looks like this:
    Code:
    DoCmd.SetWarnings False
       'Your delete code goes here, 
       'it could also be Insert/Update SQL
       'statements and so forth
    DoCmd.SetWarnings True

    Comment

    • Ryno Bower
      New Member
      • Nov 2010
      • 76

      #3
      Ok thanks. What would happen if I don't set it to true again?

      Comment

      • TheSmileyCoder
        Recognized Expert Moderator Top Contributor
        • Dec 2009
        • 2322

        #4
        Well you will have disabled all the warning messages you usually get. I do not know for sure which messages are considered warnings, so I always turn them back on after turning them off, like in the example.

        Comment

        Working...