Deleting a Table

Sam Summers

Registered User.
Local time
Today, 22:48
Joined
Sep 17, 2001
Messages
939
Hi guys,
I have searched and searched and tried all sorts of things but nothing seems to work.
I am now baffled.
I have a form that on the 'OnClose' Event i am trying to delete a table called "TableFields"

So far i have tried these statements:

CurrentDb.TableDefs.Delete "TableFields"

DoCmd.DeleteObject acTable, "TableFields"

Among others suggested but it still stays there? :confused:

There must be a way surely?

Thanks in advance
 
What is happening when you try to delete them?

Can you delete it through the control centre?

David
 
Thanks for replying.

Absolutely nothing is happening?!

It is a temporary table that is created when the form is opened but i need to delete it when the form has done its business

I'm trying to find if something may be conflicting with it but still baffled?

Here is the code at the moment:

Private Sub Form_Close().

On Error GoTo Err_Form_Unload

Dim Directory As String

Dim db As DAO.Database
Set db = CurrentDb

'delete the temporary tables
'CurrentDb.TableDefs.Delete "TableFields"
DoCmd.DeleteObject acTable, "TableFields"
db.TableDefs.Delete "tblRandom"

'db.Close

Exit_Form_Unload:
Exit Sub

Err_Form_Unload:
If Err.Number = 3265 Then '*** if the error is the query is missing
Resume Next '*** then skip the delete line and resume on the next line
ElseIf Err.Number = 3211 Then
Resume Next
Else
MsgBox Err.Description '*** write out the error and exit the sub
Resume Exit_Form_Unload
End If

End Sub
 
Hi guys,
I have searched and searched and tried all sorts of things but nothing seems to work.
I am now baffled.
I have a form that on the 'OnClose' Event i am trying to delete a table called "TableFields"

So far i have tried these statements:

CurrentDb.TableDefs.Delete "TableFields"

DoCmd.DeleteObject acTable, "TableFields"

Among others suggested but it still stays there? :confused:

There must be a way surely?

Thanks in advance

Does the code execute. I would put a breakpoint in the code and step thru it using the F8 key.

Alternatively put a MsgBox "At OnClose Event" in the Event.
 

Users who are viewing this thread

Back
Top Bottom