Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

FIX: Jet DROP TABLE with Non-Existent Table Name Returns Wrong Error Code


View products that this article applies to.

This article was previously published under Q253857

↑ Back to the top


Symptoms

When you try to drop a non-existent table using DAO 3.5, you receive the following error message:
3376 Table <name> doesn't exist.
When you try to drop a non-existent table using DAO 3.6, you receive a different error message:
3371 Can't find table or constraint.

↑ Back to the top


Cause

The first (more generic) message above is a side-effect of changing Microsoft Jet to allow dropping multiple tables at once.

↑ Back to the top


Resolution

Upgrade to Microsoft Jet 4.0 SP4 or later.

↑ Back to the top


Status

This has been fixed so that when dropping a single table and the name does not exist within the database, the old error message is given. However, if dropping multiple tables, and one or more do not exist, the new error message is given.

↑ Back to the top


More information

Steps to Reproduce

  1. In Microsoft Visual Basic 5.0 or 6.0, create a new Standard EXE project.

    In Microsoft Access 2000, open an existing database.
  2. Add a form to the project with a Command button (Command1).
  3. Add the following code to the click event of the Command button:
    Option Explicit
    
    Private Sub Command1_Click()
    Dim db As DAO.Database, E As Long
      Set db = DBEngine(0).OpenDatabase("nwind.mdb")  ' Visual Basic
    '  Set db = CurrentDB()                            ' Access 2000
      On Error Resume Next
    ' the table name must be nonexistent
      db.Execute "DROP TABLE FOO_BAR_1234", dbFailOnError
      E = Err
      Err.Clear
      MsgBox "Error should be 3376." & vbCrLf & "Actual error: " & E
      db.Execute "DROP TABLE FOO_BAR_1234, FOO_BAR_3456", dbFailOnError
      E = Err
      Err.Clear
      MsgBox "Error should be 3371." & vbCrLf & "Actual error: " & E
      db.Close
    End Sub
    					
    NOTE: You may have to adjust the path to point to a valid database.

  4. For Visual Basic, on the Project, select References or, for Access 2000, on the Tools menu, select References and choose the following type library:
    Microsoft DAO 3.6 Object Library
  5. In Visual Basic, run the project.

    In Microsoft Access, save and open the form.
  6. Click the Command button. If you are using Microsoft Jet 4.0 SP3 or earlier, the actual error number in the first message box does not match the expected error number; those in the second do match. If you are using Microsoft Jet 4.0 SP4 or later, the error numbers in both message boxes match.

↑ Back to the top


Keywords: KB253857, kbjet, kbfix, kbbug

↑ Back to the top

Article Info
Article ID : 253857
Revision : 3
Created on : 7/14/2004
Published on : 7/14/2004
Exists online : False
Views : 333