HandsOn Deleting a Stored Query

1. In the Visual Basic Editor window, choose Insert | Module.

2. In the module's Code window, type the Delete_Query procedure shown below.

3. Choose Run | Run Sub/UserForm to execute the procedure.

Sub Delete_Query()

Dim cat As New ADOX.Catalog Dim strPath As String

On Error GoTo ErrorHandler

Part II

strPath = CurrentProject.Path & "\Northwind.mdb" cat.ActiveConnection = "Provider=Microsoft.Jet.0leDb.4.0;" & _ "Data Source= " & strPath cat.Views.Delete "London Employees"


Set cat = Nothing Exit Sub


If Err.Number = 3265 Then

MsgBox "Query does not exist." Else

MsgBox Err.Number & ": " & Err.Description End If

Resume ExitHere End Sub

0 0

Post a comment