HandsOn Deleting a Stored Procedure

1. Switch to the Visual Basic Editor window and insert a new module.

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

Sub Delete_StoredProc()

Dim conn As ADODB.Connection

On Error GoTo ErrorHandler

Set conn = CurrentProject.Connection conn.Execute "DROP PROCEDURE procEnterData; " ExitHere:

If Not conn Is Nothing Then

If conn.State = adStateOpen Then conn.Close End If

Set conn = Nothing Exit Sub ErrorHandler:

If InStr(1, Err.Description, "cannot find") Then MsgBox "The procedure you want to delete " & _ "does not exist.", _

vbDefaultButton1 + vbInformation, "Request failed"


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

Resume ExitHere End Sub

0 0

Post a comment