title: How to return values from a SQL Server Stored Procedure and Utilise them in Access VBA
body: <p>I've set up a Stored Procedure in SQL Server that works fine.  I can now call it from VBA, but want to return a value to know if there were any errors etc.  The last parameter in my SP is set up as OUTPUT:</p>
  
  <pre><code>@DataSetID int = 0,
  @Destination char(1)='-',
  @errStatusOK bit OUTPUT
  </code></pre>
  
  <p>My VBA to call the SP is below, but it won't work now, after adding the new parameter and I'm not sure where I'm going wrong, I keep getting <code>3708 - Parameter object is improperly defined. Inconsistent or incomplete information was provided.</code>:</p>
  
  <pre><code>Set cnn = New adodb.Connection
  cnn.ConnectionString = 
     "DRIVER=SQL Server;SERVER=SERVER\SERVER;DATABASE=a_db;Trusted_Connection=Yes"
  
  cnn.Open cnn.ConnectionString
  
  Set cmd = New adodb.Command
  cmd.ActiveConnection = cnn
  cmd.CommandType = adCmdStoredProc
  cmd.CommandText = "stprMoveDataSet"
  
  Set param = cmd.CreateParameter
                 ("@DataSetID", adInteger, adParamInput, , stDataSet)
  cmd.Parameters.Append param
  Set param = cmd.CreateParameter
                 ("@Destination", adChar, adParamInput, 1, stDestination)
  cmd.Parameters.Append param
  Set param = cmd.CreateParameter
                 ("@errStatusOK", adBit, adParamReturnValue)
  cmd.Parameters.Append param
  
  rs.CursorType = adOpenStatic
  rs.CursorLocation = adUseClient
  rs.LockType = adLockOptimistic
  rs.Open cmd
  </code></pre>
  
  <p>How can I get the vba to work with the OUTPUT parameter and make the return value 'readable' by the vba.</p>
  
  <p>EDIT - I've changed the question to be more specifically about returning values and not just about using OUTPUT Parameters.</p>