DeleteObject - Access 2000

A

Abay

Is there a way to use DeleteObject or something else to delete all files
with names beginning with the same letters e.g. delete all files beginning
with Log_import .. tried using an * with no success ... as usual I'm
learning as I go along.

Any help would be much appreciated.

Abay
 
D

Douglas J. Steele

To delete files from your computer's hard drive through VBA, you can use the
Kill statement, which accepts wildcards:

Kill <path information>

like

Kill "C:\Data\Log_import*.txt"
 
D

Douglas J. Steele

Ah. In that case, no, there's no way to use a wild card without writing some
code.

Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef
Dim intLoop As Integer

Set dbCurr = CurrentDb()
For intLoop = (dbCurr.TableDefs.Count - 1) To 0 Step -1
Set tdfCurr = dbCurr.TableDefs(intLoop)
If InStr(1, tdfCurr.Name, "Log_import", vbTextCompare) = 1 Then
dbCurr.TableDefs.Delete tdfCurr.Name
End If
Next intLoop

I'm using InStr to ensure that it doesn't matter whether your table starts
Log_Import, or LOG_IMPORT or the like. I'm assume that the table name has to
start Log_import, hence checking that InStr returns 1 (the first position of
the string). Note that since I'm deleting tables, it's necessary to start at
the end of the list of tables and work forward.
 
Top