delete a table after used

  • Thread starter Thread starter Phil
  • Start date Start date
P

Phil

Hi,

I am using Access 97.

I have two forms (Form A and B). In form A, there is a
button to import a table (to feed data to form B) and to
open form B. When the user finishes the form B and closes
it, I would like the Access to delete the imported table
for form B. I tried the followings:

 Use Docmd.deleteobject in the both “close” and “Unload”
event of form B – did not work
 When the form B is closed, assign a value to a control
of form A. I applied the same Docmd.deleteobject code
under “Afterupdate” event of the particular control. -
did not work either.

I have no idea what else I can try. Please help or give
me some direction.

Thank you so much.
 
Try...

If TableExists("SummaryData") Then
DoCmd.DeleteObject acTable, "SummaryData"
End If

And you will need this...(Place in a Standard Module)...
Public Function TableExists(TableName As String) As Boolean
' This function will check if a table exists and return
True if it does
Dim Z As Database, Count%
Set Z = CurrentDb()
For Count = 0 To Z.TableDefs.Count - 1
If Z(Count).Name = TableName Then
TableExists = True
Z.Close: Set Z = Nothing
Exit Function
End If ' Z(Count).Name = TableName
Next Count
Z.Close: Set Z = Nothing
End Function

HTH - Bob
 
Back
Top