Dropping an Error Table

  • Thread starter Access::Student
  • Start date
A

Access::Student

Hello,
I'm drying to use VBA to delete an auto-generated error table but I can't
figure it out.
What I'm doing is running the following script from a button:

Private Sub Update_Assets_Click()
Application.DoCmd.SetWarnings False
DoCmd.RunSavedImportExport "Update_Assets"
DoCmd.OpenQuery "Add_Assets"
DoCmd.OpenQuery "Update_Assets"
DoCmd.RunSQL "DROP TABLE Database_Export;"
Application.DoCmd.SetWarnings True
End Sub

That works fine, but the Import step sometimes generates a table called
"Database_Exports$_ImportErrors" . What I tried to do was add the following
line after the other SQL line:

DoCmd.RunSQL "DROP TABLE Database_Export$_ImportErrors;"

But I get an error message and the script crashes. I have no idea why. Any
ideas?

Syntax error in DROP TABLE or DROP INDEX. (Error 3295)
 
J

Jerry Whittle

It's the $ sign. If you remove it, you can drop the table. I attempted to
surround the table name using combinations of " and ' but can't get it to
work.
 
A

Access::Student

Thanks for the reply.
I had considered that, but the problem is that it's an auto-generated table,
so I can't pick the name. I don't think there's anything I can change so that
it removes the '$'.

I'm not sure what to do.
 
J

Jerry Whittle

There should be a way to surround the table name with a combination of single
and double quotation marks so that it doesn't see the $. Something like below:

DROP TABLE "'Database_Export$_ImportErrors'";

DROP TABLE ""'Database_Export$_ImportErrors'"";
 
H

Hans Up

Access::Student said:
DoCmd.RunSQL "DROP TABLE Database_Export$_ImportErrors;"

But I get an error message and the script crashes. I have no idea why. Any
ideas?

Syntax error in DROP TABLE or DROP INDEX. (Error 3295)

Try brackets around the table name:

DoCmd.RunSQL "DROP TABLE [Database_Export$_ImportErrors];"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top