Deleting a Stored Query : SQL Update « Access « VBA / Excel / Access / Word






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

 








Related examples in the same category

1.Executing an Update Query
2.Get the updated record count
3.Executing an Update Query using the Command Object
4.Listing All Saved Queries in a Database