delete table

M

Michael Magg

Hello!

I wanna import a table with a makro, but a table with this name already
exists. So the imported table (f. i. "table") is saved as "table1". How can
I check, if such a table already exists and then delete it?
So how can I check the existence of a table?

________________________________________
Function Importieren1()
On Error GoTo Importieren1_Err

DoCmd.DeleteObject acTable, "schueler"
DoCmd.RunCommand acCmdImport


Importieren1_Exit:
Exit Function

Importieren1_Err:
MsgBox Error$
Resume Importieren1_Exit

End Function
________________________________________

Yours Jürgen
 
J

John W. Vinson [MVP]

How can I check, if such a table already exists and then
delete it?
So how can I check the existence of a table?

Don't bother checking. Just note the error number that you
get when you attempt to delete the table when it does not
exist, and trap that error. I'm posting from a computer
without Access installed and I don't recall the error
number, but the code in your error handler would be
something like

Importieren1_Exit:
Exit Function

Importieren1_Err:
Select Case Err.Number
Case xxx ' the relevant error number here
Resume Next ' just go on as if no error happened
Case Else ' any other error
MsgBox "Error " Err.Number & vbCrLf & Err.Description
Resume Importieren1_Exit



John W. Vinson/MVP
 

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