Mega Code Archive

 
Categories / VisualBasic Script / Access
 

Deleting a Stored Query

Sub Delete_Query()    Dim cat As New ADOX.Catalog    Dim strPath As String    On Error GoTo ErrorHandler    strPath = CurrentProject.Path & "\mydb.mdb"    cat.ActiveConnection = "Provider=Microsoft.Jet.OleDb.4.0;" & _       "Data Source= " & strPath    cat.Views.Delete "London Employees" ExitHere:    Set cat = Nothing    Exit Sub ErrorHandler:    If Err.Number = 3265 Then       MsgBox "Query does not exist."    Else       MsgBox Err.Number & ": " & Err.Description    End If    Resume ExitHere End Sub