title: VBA EGe error message rom Execute SP
body: <p>I have an Excel macro that executes a Stored Procedure (SQL2008 R2). The SP has  lot of error handling and rises lots of custom errors. Is there a way to get these back to VBA without using an Output parameter (assuming that would work). All I ever get back is error no -6</p>
  
  <p>Here's my code snippet  </p>
  
  <pre><code>       ' Call the SP
          Dim iReturn As Integer
          iReturn = 0
          cmd.CommandType = adCmdStoredProc
          cmd.ActiveConnection = conn
          cmd.CommandText = "EPMS_CreateInvoice"
          cmd.Parameters.Append cmd.CreateParameter("iReturn", adInteger, adParamReturnValue)
          cmd.Parameters.Append cmd.CreateParameter("@SGInvID", adInteger, adParamInput)
          cmd.Parameters.Append cmd.CreateParameter("@InvDate", adVarChar, adParamInput, 10)
          cmd.Parameters.Append cmd.CreateParameter("@PostDate", adVarChar, adParamInput, 10)
          cmd.Parameters.Append cmd.CreateParameter("@CSR", adVarChar, adParamInput, 50)
          cmd.Parameters.Append cmd.CreateParameter("@SalesRep", adVarChar, adParamInput, 20)
          cmd.Parameters.Append cmd.CreateParameter("@BillerInitials", adVarChar, adParamInput, 4)
          cmd.Parameters.Append cmd.CreateParameter("@Terms", adVarChar, adParamInput, 5)
          cmd.Parameters.Append cmd.CreateParameter("@InvNo", adVarChar, adParamInput, 20)
          cmd.Parameters.Append cmd.CreateParameter("@CustomerID", adVarChar, adParamInput, 20)
          cmd.Parameters.Append cmd.CreateParameter("@Draft", adBoolean, adParamInput)
  
  
  
          iReturn = cmd.Parameters(iReturn)
          cmd.Parameters("@SGInvID") = SGInvID
          cmd.Parameters("@InvDate") = InvoiceDate
          cmd.Parameters("@PostDate") = PostingDate
          cmd.Parameters("@CSR") = CSR
          cmd.Parameters("@SalesRep") = SalesRep
          cmd.Parameters("@BillerInitials") = BillerInitials
          cmd.Parameters("@Terms") = TermsCode
          cmd.Parameters("@InvNo") = InvoiceNo
          cmd.Parameters("@CustomerID") = CustomerID
          cmd.Parameters("@Draft") = Draft
  </code></pre>
  
  <p>Thanks</p>
  
  <p>Mark</p>