Reputation: 405
I keep getting an error when I run this code from the error handler.
All I need to do is pass a variable to the stored procedure I have created, I have a form that which contains a List View and a reactivate button.
When I select the questionnaire in the List view and then click reactivate it should send the valid questionnaire ID to the stored procedure.
Here is the code :
Private Sub btnReActivate_Click()
strModuleName = "frmReport.Reactivate"
Dim oConn As ADODB.Connection
Dim objCmd As New ADODB.Command
On Error GoTo ErrorHandler
Set oConn = GetConnection
If oConn.State = adStateOpen Then
Set objCmd = Nothing
With objCmd
.CommandText = "sproc_Reactivate"
.CommandType = adCmdStoredProc
.ActiveConnection = oConn
' Refresh the parameters collection and populate it
.Parameters.Append _
objCmd.CreateParameter("@ID", adInteger, adParamInput, , Mid(LV.SelectedItem.Key, 2, Len(LV.SelectedItem.Key) - 2))
End With
' Execute the command
objCmd.Execute
End If
ErrorHandler:
MsgBox GetMessage("frmModule1", 1, True, "Module: " & strModuleName & " Line: " & Erl & " - " & Err.Number, Err.Description), vbCritical, "Manage"
End Sub
I'm getting: "An error occurred ref:[Module frmReport.Reactivate Line: 0-0]-[]"
Upvotes: 1
Views: 333
Reputation: 5477
Your code is a little bit incomplete, as it is missing the ErrorHandler part, but is there an Exit Sub
before the ErrorHandler:
label? It almost seems, from the error, that the function succeeds but then falls into the ErrorHandler routine via normal code flow.
Usually, in VB6, the error handler form is:
On Error GoTo MyErrorHandler
... lots of code here
'If we reach this point, we have a successful exit
Exit Sub
MyErrorHandler:
... Code to display/handle error here ....
Upvotes: 3