Prevent warning message

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mihail
    Contributor
    • Apr 2011
    • 759

    Prevent warning message

    Hi !
    I have a table named ... "Tbl" .
    If I run a MAKE TABLE query to make table (again) named "Tbl" then I receive an warning message: "The table already exist... Do you wish to replace it ?"

    Can I disable this warning ?

    More: How to remove a table from VBA ?

    Note: I disable warning messages from ACCESS OPTIONS when I run an ACTION QUERY.

    Thank you !
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    You can disable warning messages in VBA, by typing:
    Code:
    Docmd.SetWarnings False
      Docmd.RunSql ....
    Docmd.SetWarnings True
    I personally always turn warnings back on immediately after performing my query.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32656

      #3
      That only effects Warning messages. Error messages still show in that situation.

      I'm not sure whether this message is a Warning message or an Error message (though I do believe it's only a Warning), so if that doesn't do it you can remove the table by saying :
      Code:
      Call DoCmd.DeleteObject(acTable,"TableName")

      Comment

      • Mihail
        Contributor
        • Apr 2011
        • 759

        #4
        Thank you all !

        To remove the table also can be used:
        Code:
                SQL = "DROP TABLE TableName"
                DoCmd.RunSQL (SQL)
        This technique (REMOVE TABLE - MAKE TABLE) also solve a part of other question: How to pass values to ListBox.RowSour ce (or Form.RecordSour ce):
        I run a few SQL to make some tables as I need, then I based SQL for ListBox.RowSour ce (Form.RecordSou rce) on this new tables, so no more need parameters.

        Is ugly too but not as ugly as at the beginnings.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32656

          #5
          That makes sense. To be fair, as with most things, there are a variety of ways to accomplish the same task. If you prefer to work within SQL then your way is fine.

          Comment

          Working...