B
Bryan Hughes
Hello,
I have some temp tables that I want to delete before my db closes.
I already have a OnLoad and OnUnlaod event that runs when the db first
opens.
On the UnLoad event I would like to search my db and delete any table that
ends with "Temp".
I have a sub that will do this but it is causing problems
Set dbs = CurrentDb()
dbs.TableDefs.Refresh
intTables = 0
For I = dbs.TableDefs.Count - 1 To 0 Step -1
Set tdf = dbs.TableDefs(I)
strTableName = tdf.Name
If Right(strTableName, 4) = "Temp" Then
DoCmd.DeleteObject acTable, strTableName
End If
Next I
dbs.Close
Set tdf = Nothing
Set dbs = Nothing
I know there is a better way to do this can you please help?
-TFTH
Bryan
I have some temp tables that I want to delete before my db closes.
I already have a OnLoad and OnUnlaod event that runs when the db first
opens.
On the UnLoad event I would like to search my db and delete any table that
ends with "Temp".
I have a sub that will do this but it is causing problems
Set dbs = CurrentDb()
dbs.TableDefs.Refresh
intTables = 0
For I = dbs.TableDefs.Count - 1 To 0 Step -1
Set tdf = dbs.TableDefs(I)
strTableName = tdf.Name
If Right(strTableName, 4) = "Temp" Then
DoCmd.DeleteObject acTable, strTableName
End If
Next I
dbs.Close
Set tdf = Nothing
Set dbs = Nothing
I know there is a better way to do this can you please help?
-TFTH
Bryan