Deleting Database Files

There is no SQL statement that allows deleting entire database files. However, if you need to delete a database file, you can use the VBA Kill statement (as shown in Hands-On 19-5).

©Hands-On 19-5: Deleting a Database File

This hands-on requires prior completion of Hands-On 19-3.

1. In the Visual Basic Editor window, insert a new module.

2. In the module's Code window, enter the DeleteDbFile procedure as shown below.

Sub DeleteDbFile()

Dim strFile As String strFile = CurrentProject.Path & "\Sites.mdb"

If Dir(strFile) <> "" Then Kill strFile

MsgBox "The database file " & strFile & _ " was successfully deleted."

End If End Sub

0 0

Post a comment