I got this error "object variable or with block variable not set"
Below is my code
Module 1
Public Function tracePackageError(Optional oPackage As DTS.Package) As String
Dim ErrorCode As Long
Dim ErrorSource As String
Dim ErrorDescription As String
Dim ErrorHelpFile As String
Dim ErrorHelpContext As Long
Dim ErrorIDofInterfaceWithError As String
Dim i As Integer
For i = 1 To oPackage.Steps.Count
If oPackage.Steps(i).ExecutionResult = DTSStepExecResult_Failure Then
oPackage.Steps(i).GetExecutionErrorInfo ErrorCode, ErrorSource, ErrorDescription, _
ErrorHelpFile, ErrorHelpContext, ErrorIDofInterfaceWithError
tracePackageError = oPackage.Steps(i).Name & " failed" & vbCrLf & ErrorSource & vbCrLf & ErrorDescription
Exit Function
End If
Next i
End Function
Form 1 call my function
Private Sub Command1_Click()
If tracePackageError <> "" Then
MsgBox "error occured:" & vbCrLf & tracePackageError
End If
End Sub
Error : "object variable or with block variable not set"